1. Configure in config file
' Mailer ' => [
' class ' => ' Yii\swiftmailer\mailer ',//server class
' Usefiletransport ' =>false,//must have, false send mail, true just generate messages under Runtime folder, do not send mail </span>
' transport ' => [
' class ' => ' Swift_smtptransport ',//Use of Classes
' host ' => ' smtp.qq.com ',//mailbox Service one address
' username ' => ' 1806001025@qq.com ',//email address, send email
' password ' => ' *********** ', //fill in the Mailbox password
' port ' => ' 465 '. Server Port
' encryption ' => ' SSL ',//encryption mode
],
' messageconfig ' =>[' charset ' => ' UTF-8 '
,//code
' from ' =>[' 1806001025@qq.com ' => ' admin ' ///e-mail address and name displayed in message
],
The above configuration, according to your mailbox, to configure. 2: Inside the controller or inside the model you can call the
$FFF = Yii:: $app->mailer->compose ()
->setfrom ([' 1806001025@qq.com ' => ' I see you are stupid '])//and corresponds to the From field above can write only one
->setto (' 429281869@qq.com ')
->setsubject (' dsfsfsddddddddddddddddddddddddddd ')
- >settextbody (' sdfffffffffffffffffffffffffffff ')
->send ();
3: If the QQ mailbox Open POP3/SMTP Service
QQ Mailbox-> Set-"account"
4: After sending the message, is this appearance, pay attention to the above settings, you know how to get it.
、
It is believed that you will understand it. Haha, come on together .