Yii2使用swiftmailer发送邮件的方法
发布时间:2020-12-12 21:28:57 所属栏目:PHP教程 来源:网络整理
导读:本篇章节讲解Yii2使用swiftmailer发送邮件的方法。供大家参考研究具体如下: [ 'class' => 'yiiswiftmailerMailer','viewPath' => '@backend/mail','useFileTransport' => false,//set this property to false to send mails to real email addr
本篇章节讲解Yii2使用swiftmailer发送邮件的方法。分享给大家供大家参考,具体如下: [
'class' => 'yiiswiftmailerMailer','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程序设计有所帮助。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |