任何知道如何在用户成功后在系统上注册信息后将验证发送到电子邮件的人......我希望任何人都可以逐步解释....我应该在此编辑还是有任何解决方案或建议:< / p>
Yii::$app->mail->compose()
->setFrom('somebody@domain.com')
->setTo('myemail@yourserver.com')
->setSubject('Email sent from Yii2-Swiftmailer')
->send();
我已经像这样配置了swiftmailer:
'mail' => [
'class' => 'yii\swiftmailer\Mailer',
'transport' => [
'class' => 'Swift_SmtpTransport',
'host' => 'localhost',
'username' => 'username',
'password' => 'password',
'port' => '587',
'encryption' => 'tls',
],
答案 0 :(得分:0)
您应该使用邮件配置&#39;而不是邮件&#39;像这样
设置'useFileTransport' => false
在这种情况下设置邮件服务器的传输是gmail 如果您使用其他邮件服务器,则必须正确设置相关参数。
'components' => [
.........
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
'viewPath' => '@common/mail',
// send all mails to a file by default. You have to set
// 'useFileTransport' to false and configure a transport
// for the mailer to send real emails.
//'useFileTransport' => true,
'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' => 'yourusername@gmail.com',
'password' => 'yourpassword',
'port' => '587',
'encryption' => 'tls',
],
],