php 邮件类库,[3.3]-扩展类库:基于PHPMailer的邮件发送 | PhalApi(π框架) - PHP轻量级开源接口框架 - 接口,从简单开始!...

3.3.1 扩展类库:基于PHPMailer的邮件发送

此扩展可用于发送邮件。

3.3.2 安装和配置

从 PhalApi-Library 扩展库中下载获取 PHPMailer 包,如使用:

$ git clone https://git.oschina.net/dogstar/PhalApi-Library.git

然后把 PHPMailer 目录复制到 ./PhalApi/Library/ 下,即:

$ cp ./PhalApi-Library/PHPMailer/ ./PhalApi/Library/ -R

到此安装完毕!接下是插件的配置。

(1)邮箱配置

需要在 ./Config/app.php 配置文件中追加以下配置:

'PHPMailer' => array(

'email' => array(

'host' => 'smtp.gmail.com',

'username' => 'XXX@gmail.com',

'password' => '******',

'from' => 'XXX@gmail.com',

'fromName' => 'PhalApi团队',

'sign' => '
请不要回复此邮件,谢谢!
-- PhalApi团队敬上 ',

),

),

3.3.3 使用

如下代码示例:

require_once './init.php';

DI()->loader->addDirs('Library');

$mailer = new PHPMailer_Lite(true);

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

稍候将会收到:

20150411005257_6e6c7a610357cf80e4513557a110d86d

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

$addresses = array('chanzonghuang@gmail.com', 'test@phalapi.com');

$mailer->send($addresses, 'Test PHPMailer Lite', 'something here ...');

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值