无法从测试网站yii2 swiftmailer发送邮件

时间:2018-08-02 05:50:30

标签: linux yii2 swiftmailer

我的服务器基于Linux。请为我提供正确的邮件程序配置

'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',
                'port' => '465',
                'encryption' => 'ssl',              
            ],
        ],

1 个答案:

答案 0 :(得分:0)

对于gmail应该使用端口587加密tls

        'transport' => [
            'class' => 'Swift_SmtpTransport',
            'host' => 'smtp.gmail.com',
            'username' => 'your.username@gmail.com',
            'password' => 'yourpassword',
            'port' => '587',
            'encryption' => 'tls',
        ],