Yii2使用swiftmailer发送邮件的方法

前端之家收集整理的这篇文章主要介绍了Yii2使用swiftmailer发送邮件的方法前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

本文实例讲述了Yii2使用swiftmailer发送邮件方法分享给大家供大家参考,具体如下:

[ 'class' => 'yii\swiftmailer\Mailer','viewPath' => '@backend/mail','useFileTransport' => false,//set this property to false to send mails to real email addresses //comment the following array to send mail using PHP's mail function 'transport' => [ 'class' => 'Swift_SmtpTransport','host' => 'smtp.gmail.com','username' => 'username@gmail.com','password' => 'password','port' => '587','encryption' => 'tls',],

控制器:

mail->compose('your_view',['params' => $params]) ->setFrom([\Yii::$app->params['supportEmail'] => 'Test Mail']) ->setTo('to_email@xx.com') ->setSubject('This is a test mail ' ) ->send();

更多关于Yii相关内容感兴趣的读者可查看本站专题:《》、《》、《》、《》、《》、《》、《》及《

希望本文所述对大家基于Yii框架的PHP程序设计有所帮助。

原文链接:https://www.f2er.com/php/19884.html

猜你在找的PHP相关文章