dev-master
9999999-dev https://www.phalapi.net/PhalApi 2.x扩展类库,基于PHPMailer的邮件发送。
GPL-3.0+
The Requires
phpmailer phalapi phalapi-phpmailer
Wallogit.com
2017 © Pedro Peláez
PhalApi 2.x扩展类库,基于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)
, (*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"}
PhalApi 2.x扩展类库,基于PHPMailer的邮件发送。
GPL-3.0+
phpmailer phalapi phalapi-phpmailer