2016-05-05 96 views
1

我使用yii2框架工作,我在我的web.php文件中實現了快速郵件程序。它的工作正常。SMTP服務器問題迅捷郵件

我的配置代碼:

'mailer' => [ 
     'class' => 'yii\swiftmailer\Mailer', 
     'useFileTransport'=>false, 
     'transport' => [ 
      'class' => 'Swift_SmtpTransport', 
    ``   'host' => 'smtp.gmail.com', 
      'username' => '[email protected]', 
      'password' => 'TECHEDGE', 
      'port' => '465', 
      'encryption' => 'ssl', 
     ], 
    ], 

,但我得到當我實現在服務器端同樣的事情,我有以下響應的問題:

預期的響應代碼250,但得到的代碼「535」,隨着消息「535-5.7.8用戶名和密碼不被接受,瞭解更多 535 5.7.8 https://support.google.com/mail/answer/14257 k8sm2888892qke.45 - gsmtp

任何幫助,感謝..

回答

0

配置快捷郵件象下面這樣:

'mailer' => [ 
      'class' => 'yii\swiftmailer\Mailer', 
      'viewPath' => '@common/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' => 'TECHEDGE', 
      'port' => '587', 
      'encryption' => 'tls', 
         ], 
      // 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. 
     ], 

https://www.google.com/settings/security/lesssecureapps並打開訪問不夠安全的應用

+0

我使用上面的代碼,但我得到了在無效的路徑別名迴應:@通用/郵件。 –

+0

確定你可以刪除該行,如果你不使用模板。 'viewPath'=>'@ common/mail', – jithin

+0

在本地主機它的工作很好。但在服務器端沒有郵件lesssecureapp trun on。 –