Make sure you have initialised your application in production environment to send emails from your application,else it will be written in to the mailoutput folder.Or manually edit the config file like follows.
In the components's section of your common/main-local.php
'mail' => [
'class' => 'yiiswiftmailerMailer',
'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' => '[email protected]',
'password' => 'password',
'port' => '587',
'encryption' => 'tls',
],
],
In your Controller
Yii::$app->mail->compose('your_view', ['params' => $params])
->setFrom([Yii::$app->params['supportEmail'] => 'Test Mail'])
->setTo('[email protected]')
->setSubject('This is a test mail ' )
->send();
This should work! Hope this will help you!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…