Send e-mail configuration:
Open the configuration file, add the following code to the components => [...] in (Example: Advanced default configuration /common/config/main-local.php)
'Mailer' => [ 'class' => 'Yii \ swiftmailer \ Mailer', 'viewPath' => '@ the Common / mail', 'useFileTransport' => false , // here we must change the false, otherwise messages are not send 'Transport' => [ 'class' =>' Swift_SmtpTransport ', ' Host '=>' smtp.163.com ', ' username '=>' [email protected] ', ' password '=>' * ******** ', // if the mailbox is 163, here to fill in the authorization code ' Port '=>' 25 ', 'Encryption '=>' tls', // 'Port' => '994', // if tls ssl protocol converter can not send // 'encryption' => 'ssl ', ], ],
/ * * * @Param the setFrom Action ([ 'In Email' => 'name']) sender email => Sender name * @param Action setTo ( 'In Email') Recipient In Email * @param Action $ the setSubject email heading * / $ mail = \ Yii :: $ App -> mailer-> Compose () -> setFrom ([ '[email protected]' => 'Yii Chinese network' ]) -> setTo ( '391 430 388 @ QQ .com ' ) -> setSubject (' e-mail sending configuration ' ) // -> setTextBody (' Yii Chinese web tutorials nice www.yii-china.com ') // release text text -> setHtmlBody ( "<br> ! Yii Chinese network tutorial nice www.yii-china.com ") // release can be tagged with html text ->send(); if($mail) echo 'success'; else