//以aliyun企业邮为例,在config/web.phpd的'components'里面配置
'urlManager' => [
....
],
'mailer' => [
'class' =>'yii\swiftmailer\Mailer',
// send all mails to a file bydefault. You have to set
//'useFileTransport' to falseand configure a transport
//for the mailer to send real emails.
'useFileTransport' =>false,
'transport' => [
'class' =>'Swift_SmtpTransport',
'host' =>'smtp.mxhichina.com',
'username' =>'support@XXX.com',
'password' =>'XXX',
'port' =>'25',
'encryption' =>'tls',
],
'messageConfig'=>[
'charset'=>'UTF-8',
'from'=>['support@XXX.com'=>'发送人']
],
],