1. Configure in config file
' Mailer ' = [ ' class ' = ' yii\Swiftmailer\mailer ',//server class
' Usefiletransport ' =>false,//This sentence must have, false send message , true just generate mail in the runtime folder, do not send mail ' transport ' = > [ ' class ' = 'Swift_smtptransport ',//Use the class ' host ' = ' smtp.qq.com ',//email service an address ' Username ' + ' 1806001025@qq.com ',//e-mail address, send the mailbox ' password ' = ' *********** ', //fill in your email password ' port ' = > ' 465 ',// server Port ' encryption ' + ' SSL ',//encryption Method ], ' messageconfig ' =>[ ' charset ' = ' UTF-8 ',//code ' from ' =>[' 1806001025@qq.com ' [admin '] //e-mail address and name displayed in the message ], ]
The above configuration needs to be configured according to your mailbox.
2: You can call the
$FFF = Yii:: $app->mailer->compose () ->setfrom ([' 1806001025@qq.com ' = ' I see you as silly '])//and corresponding to the From field above can write only one ->setto (' 429281869@qq.com ') ->setsubject (' dsfsfsddddddddddddddddddddddddddd ') - >settextbody (' sdfffffffffffffffffffffffffffff ') ->send ();
Copyright NOTICE: This article for Bo Master original article, there is the wrong place to welcome correct.
The above describes the YII2 send mail (Configure the QQ version), including e-mail, send mail, swift content, I hope the PHP tutorial interested in a friend helpful.