Yii2 smtp电子邮件不适用于godaddy

时间:2016-12-15 13:49:17

标签: yii2 smtp

我已将Yii2网站从一台服务器部署到godaddy。它显示错误: -

'If you receive error " Connection could not be established with host smtp.gmail.com [Connection refused #111] "'

我在下面设置了邮件配置: -

'mailer' => [
        'class' => 'yii\swiftmailer\Mailer',
        'viewPath' => '@common/mail',
        'transport' => [
            'class' => 'Swift_SmtpTransport',
            'host' => 'smtp.gmail.com',
            'username' => 't********m@gmail.com',
            'password' => '***************',
            'port' => '465',
            'encryption' => 'tls', //depends if you need it
        ],
    ],

1 个答案:

答案 0 :(得分:1)

我只是通过评论传输标签来解决它: -

'mailer' => [
    'class' => 'yii\swiftmailer\Mailer',
    'viewPath' => '@common/mail',
    //'transport' => [
      //  'class' => 'Swift_SmtpTransport',
       // 'host' => 'smtp.gmail.com',
       // 'username' => 't********m@gmail.com',
       // 'password' => '***************',
       // 'port' => '465',
       // 'encryption' => 'tls', //depends if you need it
    // ],
],