yii框架中的邮件发送
来源:互联网 发布:服装设计都用什么软件 编辑:程序博客网 时间:2024/05/08 21:02
1.在config中的web.php中加入如下一段话
'components' => ['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. //'viewPath' => 'views\mail', 'useFileTransport' => false, //'class' => 'yii\swiftmailer\Mailer', 'transport' => [ 'class' => 'Swift_SmtpTransport', 'host' => 'smtp.163.com', 'username' => '13020025757@163.com', 'password' => '*******', 'port' => '25', 'encryption' => '', ], 'messageConfig'=>[ 'charset'=>'UTF-8', 'from'=>['13020025757@163.com'=>'admin'] ],],]
2.控制器里调用
$bool= Yii::$app->mailer->compose() ->setFrom('13020025757@163.com')//这里必须和web.php里的from相同 ->setTo('1234567989@qq.com') ->setSubject('Message subject') ->setTextBody('Plain text content') ->setHtmlBody('点我 http://www.setpember.com/yuekao/web/index.php?r=discount/get&d_id='.$arr['dis_id'].'&d_user='.$arr['email']." 领券") ->send();if($bool){ return $this->success(['discount/index'], '发送成功');}
0 0
- yii框架中的邮件发送
- Yii框架发送邮件
- yii 框架 发送邮件
- Yii框架发送邮件
- yii框架邮件发送
- Yii 框架邮件的发送
- Yii框架的邮件发送
- yii 框架用swiftmailer 发送邮件
- yii 框架用swiftmailer 发送邮件
- 使用yii框架实现邮件发送
- 用yii发送邮件
- YII邮件发送
- Yii 邮件发送
- YII 邮件发送功能
- yii邮件发送
- yii 邮件发送
- YII 简单邮件发送
- yii 邮件发送
- CodeForces 339D Xenia and Bit Operations
- Common Gateway Interface
- 51nod 1007 正整数分组(平分) 01背包
- HDU2553N皇后问题
- HDOJ 5773 The All-purpose Zero(LIS)
- yii框架中的邮件发送
- java反射机制
- 用eval()把json转成对象时遇空格报错的处理
- 【BFS && DFS】模块小结
- 自定义AlertDialog中EditText无法输入
- 重写与重载的区别
- 【手把手教程】——Zookeeper注册中心的安装
- Leetcode 63. Unique Paths II (Medium) (cpp)
- xml接口类型的数据(把其中的数据显示出来)