yii 框架用swiftmailer 发送邮件
2016-07-11 21:46
627 查看
1.先在配置文件中 config/web.php 中修改配置文件
'mailer' => [ 'class' => 'yii\swiftmailer\Mailer', // send all mails to a file by default. You have to set // 'useFileTransport' to false and configure a transport // for the mailer to send real emails. 'useFileTransport' => false, //'class' => 'yii\swiftmailer\Mailer', 'transport' => [ 'class' => 'Swift_SmtpTransport', 'host' => 'smtp.163.com', 'username' => 'm18612193548@163.com', 'password' => 'n1234567890', 'port' => '25', 'encryption' => null, ], 'messageConfig'=>[ 'charset'=>'UTF-8', 'from'=>['m18612193548@163.com'=>'admin'] ], ],
2 。在控制器里加入以下代码进行测试
Yii::$app->mailer->compose() ->setFrom('m18612193548@163.com') ->setTo('1297192749@qq.com') ->setSubject('Message subject') ->setTextBody('Plain text content') ->setHtmlBody('<b>傻蛋</b>') ->send();
相关文章推荐
- iOS8自定义Collection View Cell - Swift教程
- swift学习笔记
- Swift基础(六)解包
- Swift基础(五)字典
- Swift基础(四)数组
- Swift -banner滚动图自定义
- Swift - 与OC混编时如何创建桥接头文件
- Swift - 协议(protocol)
- Swift - 文件,文件夹操作大全
- Swift - 文本标签(UILabel)的用法
- Swift - 按钮(UIButton)的用法
- 使用 Xcode 的 Target 区分开发和生产环境
- 成长小计-Swift中 as、as!、as?
- target XXX do ->end 常见问题
- 成长小计Swift引入三方库报错问题
- 使用 Swift 在 iOS 10 中集成 Siri —— SiriKit 教程(Part 1)
- Swift之旅 1 变量、常量和声明
- xxx-Bridging-Header.h找不到CocoaPods管理的第三方库.h文件
- swift 高仿爱鲜蜂
- iOS 图文混排 (Swift版)