我與yii2有錯誤,我無法通過yii用電子郵件帳戶發送電子郵件。如果我的密碼是正確的:( 這是我的代碼:yii2中未接受用戶名和密碼
web.php
'mailer' => [
'class' => 'yii\swiftmailer\Mailer',
'transport' => [
'class' => 'Swift_SmtpTransport',
'host' => 'smtp.gmail.com',
'username' => '[email protected]',
'password' => 'passwd',
'port' => '587',
'encryption' => 'tls',
],
],
'log'
Controller.php這樣
Yii::$app -> mailer -> compose()
-> setFrom('[email protected]')
-> setTo('[email protected]')
-> setSubject('Test')
-> setTextBody('Plain text content')
-> setHtmlBody('It is a test')
-> send();
請將錯誤粘貼到問題中。 – starf