dsgsdg206050 2016-10-15 12:20
浏览 68
已采纳

Yii swiftmailer无法在实时服务器中工作

Am using yii2 and i have setup a mailer as follows

  <?php
  return [
   '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' => false,
        'transport' => [
            'class' => 'Swift_SmtpTransport',
            'host' => 'smtp.gmail.com',
            'username' => 'myemail@gmail.com',
            'password' => 'mygmailpassword',
            'port' => '465',
            'encryption' => 'ssl',
        ],
    ],
],

];

The above works perfectly in localhost but fails when i upload to the live server i always get an error of bad credentials

The error is

Swift_TransportException

 Expected response code 250 but got code "535", with message "535-5.7.8     
Username and Password not accepted. Learn more at

535 5.7.8 https://support.google.com/mail/?p=BadCredentials 
r199sm3707144wme.1 - gsmtp

"

What could be wrong,

  • 写回答

1条回答 默认 最新

  • douwu8251 2016-10-15 12:54
    关注

    I use this config for gmail (and work)

            'transport' => [
                'class' => 'Swift_SmtpTransport',
                'host' => 'smtp.gmail.com',
                'username' => 'myname.mylast@gmail.com',
                'password' => 'mypass',
                'port' => '587',
                'encryption' => 'tls',
            ],
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵