Yii2 uses swiftmailer to send emails, yii2swiftmailer
This example describes how Yii2 uses swiftmailer to send emails. We will share this with you for your reference. The details are as follows:
'Mail' => ['class' => 'yii \ swiftmailer \ Mailer ', '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' => '123 ', 'encryption '=> 'tls',],
Controller:
Yii: $ app-> mail-> compose ('your _ view', ['params' => $ params])-> setFrom ([\ Yii :: $ app-> params ['orortemail'] => 'test mail'])-> setTo ('to _ email@xx.com ')-> setSubject ('this is a Test mail ') -> send ();