Maison  >  Article  >  php教程  >  超优美、便捷的邮件发送扩展tp-mailer, 支持所有框架

超优美、便捷的邮件发送扩展tp-mailer, 支持所有框架

WBOY
WBOYoriginal
2016-12-05 13:27:441573parcourir

已支持所有ThinkPHP版本框架以及其他任何PHP框架,支持手动引入自动载入文件
,使用方便,功能强大,支持ThinkPHP自带模板引擎,支持HTML模板,支持纯文本模板,也支持带中文的附件发送,支持邮件中嵌入图片元数据,代码连贯调用,超级优美,基于SwiftMailer开发
先看看优雅的使用:use mailer\tp5\Mailer;<br> <br> $mailer = Mailer::instance();<br> $mailer->from('tianpian0805@gmail.com', 'yuan1994')<br>     ->to('your-mail@domain.com')<br>     ->subject('纯文本测试')<br>     ->text('欢迎您使用Tp Mailer')<br>     ->send();require_once '/path/to/tp-mailer/src/autoload.php';<br> <br> use mailer\tp32\Mailer;<br> <br> $mailer = Mailer::instance();<br> $mailer->from('tianpian0805@gmail.com', 'yuan1994')<br>     ->to('your-mail@domain.com')<br>     ->subject('多行文本测试')<br>     ->line('PHPer们: ')<br>     ->line('欢迎你们使用Tp Mailer, 如果使用感觉很方面请给个Star, 也欢迎大家Fork帮忙完善')<br>     ->line()<br>     ->line('yuan1994 <tianpian0805></tianpian0805>     ->attach('/path/to/文件名.pdf', '自定义文件名.pdf')<br>     ->send();require_once '/path/to/tp-mailer/src/autoload.php';<br> <br> use mailer\tp31\Mailer;<br> <br> $mailer = Mailer::instance();<br> $mailer->send(function($mailer, $message) {<br>     $mailer->to('tianpian0805@gmail.com')<br>         ->subject('使用框架模板引擎渲染模板测试')<br>         ->view('mail:test', array(<br>             'param1' => '参数1',<br>             'param2' => '参数2',<br>             'embed:image' => ROOT_PATH . 'image.jpg',<br>         ));<br> });安装:
使用 Composer 安装 (强烈推荐):

支持 psr-4 规范, 开箱即用

composer require yuan1994/tp-mailer
github下载 或 直接手动下载源码:
需手动引入自动载入文件
下载文件:

git clone https://github.com/yuan1994/tp-mailer tp-mailer

git clone https://github.com/swiftmailer/swiftmailer swiftmailer

或者点击直接下载:

https://github.com/yuan1994/tp-mailer/archive/master.zip

https://github.com/swiftmailer/swiftmailer/archive/5.x.zip

移动文件夹:

然后将两个项目分别手动命名为 tp-mailer 和 swiftmailer, 放在自己项目的扩展类库文件夹里, 这两个文件夹必须在同一目录, 目录结构大概如下所示:

扩展目录
├── tp-mailer
│ └── src
├── swiftmailer
│ ├── lib
│ ├── doc
│ └── tests
引入自动载入文件:

使用时引入或者全局自动引入

require_once '/path/to/tp-mailer/src/autoload.php;


项目地址:
https://github.com/yuan1994/tp-mailer

文档地址:
https://github.com/yuan1994/tp-mailer

如果有问题请提交 Issues
https://github.com/yuan1994/tp-mailer/issues

其他项目推荐:
tpAdmin:基于tp5的支持代码自动生成、Rbac权限管理的后台管理框架
https://github.com/yuan1994/tpAdmin

WeChat_Web_Devtools Linux版:完美支持Linux系统的微信小程序开发工具:
https://github.com/yuan1994/wechat_web_devtools

Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn