2017 © Pedro Peláez
 

library phpmailer

PhalApi 2.x扩展类库,基于PHPMailer的邮件发送。

image

phalapi/phpmailer

PhalApi 2.x扩展类库,基于PHPMailer的邮件发送。

  • Sunday, September 3, 2017
  • by dogstarhuang
  • Repository
  • 1 Watchers
  • 1 Stars
  • 254 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 1 Versions
  • 25 % Grown

The README.md

PHPMailer

PhalApi 2.x扩展类库,基于PHPMailer的邮件发送。, (*1)

安装和配置

修改项目下的composer.json文件,并添加:, (*2)

    "phalapi/phpmailer":"dev-master"

然后执行composer update,如果PHP版本过低,可使用composer update --ignore-platform-reqs。, (*3)

安装成功后,添加以下配置到./config/app.php文件:, (*4)

    'PHPMailer' => array(
        'email' => array(
            'host' => 'smtp.gmail.com',
            'port' => 465,
            'Secure' => 'ssl',
            'username' => 'XXX@gmail.com',
            'password' => '******',
            'from' => 'XXX@gmail.com',
            'fromName' => 'PhalApi团队',
            'sign' => '<br/><br/>请不要回复此邮件,谢谢!<br/><br/>-- PhalApi团队敬上 ',
        ),
    ),

注册

在./config/di.php文件中,注册邮件服务:, (*5)

$di->mailer = function() {
    return new \PhalApi\PHPMailer\Lite(true);
};

上面将依赖composer版本的PHPMailer;如果你的PHP版本 <= PHP 5.3,则需要切换到第一版本:, (*6)

$di->mailer = function() {
    return new \PhalApi\PHPMailer\LiteOne(true);
};

使用

如下代码示例:, (*7)

\PhalApi\DI()->mailer->send('chanzonghuang@gmail.com', 'Test PHPMailer Lite', 'something here ...');

稍候将会收到:, (*8)

123123, (*9)

如果需要发送邮件给多个邮箱时,可以使用数组,如:, (*10)

$addresses = array('chanzonghuang@gmail.com', 'test@phalapi.com');
\PhalApi\DI()->mailer->send($addresses, 'Test PHPMailer Lite', 'something here ...');

调试日志

在注册初始化时,传入true可开启调试日志,并可以看到类如:, (*11)

2017-09-03 10:10:58|DEBUG|Succeed to send email|{"addresses":["chanzonghuang@gmail.com"],"title":"Test PHPMailer Lite"}

The Versions

03/09 2017

dev-master

9999999-dev https://www.phalapi.net/

PhalApi 2.x扩展类库,基于PHPMailer的邮件发送。

  Sources   Download

GPL-3.0+

The Requires

 

phpmailer phalapi phalapi-phpmailer