2016-05-05 95 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。 –