Advanced Yii 2.0 Swiftmailer does not work with gmail

I am trying to configure swiftmailer in an extended yii 2.0 template. I went through a lot of messages, and I understand that there are some problems with gmail. My development environment in development is as follows:

'mailer' => [
        'class' => 'yii\swiftmailer\Mailer',
        'viewPath' => '@common/mail',
        'useFileTransport' => false,
        'transport' => [
            'class' => 'Swift_SmtpTransport',
            'host' => gethostbyname('smtp.gmail.com'),
            'username' => 'xxx@gmail.com',
            'password' => 'xxssxxxx',
            'port' => '465',
            'encryption' => 'ssl'
        ]

I also installed the support email that was used in the controller to the same gmail address in the main local config shown above. I tried switching to a less secure configuration for applications in my gmail account, and it didn’t work, and I don’t really like to change it. I get the following error when I use ssl encryption

unable to connect to host ... [# 0]

If I do not specify encryption, I get a timeout error.

OpenSSL phpinfo, . TLS , , (: '587' encryption = 'tls'),

stream_socket_enable_crypto(): SSL 1. OpenSSL : : 14090086: SSL: SSL3_GET_SERVER_CERTIFICATE:

, ? ? ?

+4
5

:

'mailer' => [
    'class' => 'yii\swiftmailer\Mailer',
    'viewPath' => '@common/mail',
    'useFileTransport' => false,
    'transport' => [
        'class' => 'Swift_SmtpTransport',
        'host' => gethostbyname('smtp.gmail.com'),
        'username' => 'xxx@gmail.com',
        'password' => 'xxssxxxx',
        'port' => '465',
        'encryption' => 'ssl',
        'streamOptions' => [ 
            'ssl' => [ 
                'allow_self_signed' => true,
                'verify_peer' => false,
                'verify_peer_name' => false,
            ],
        ]
    ]
+10

gmail smtp IP

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

FQDN DNS-

+2

gmail: tls, 587 smtp.gmail.com (, gethostbyname ('smtp.gmail.com') ) .

 'transport' => [
            'class' => 'Swift_SmtpTransport',
            'host' => 'smtp.gmail.com',
            'username' => 'yourUsername@gmail.com',
            'password' => 'yourPassword',
            'port' => '587',
            'encryption' => 'tls',
        ],
+1

, :

. .

 'components'=>[
        'mailer' => [
           'class' => 'yii\swiftmailer\Mailer',
           'viewPath' => '@app/mail',
           'useFileTransport' => false,
           'transport' => [
              'class'=>'Swift_SmtpTransport',
              'host'=>'smtp.gmail.com', //sample
              'username'=>'my@emaul.com', //sample email
              'password'=>'~!@#$%%^&&', // sample password
              'port'=>'465', // gmail ssl use port 465, 
              'encryption'=>'ssl',
           ],
       ],
    ],
0

: tls , ssl.

, , "tls" "ssl", .

, -.

0

All Articles