Avoid emails from gmail with swift mailer in yii2

0

I am trying to configure my yii2 application to send emails from my gmail account, I have already enabled "Allow access to less secure applications" in my account. I configured the swift mailer as shown below, everything else (Model and Controller) I leave it as it comes by default in the basic template of yii2. When I try to send the mail I get the error Swift_TransportException "Connection could not be established with host smtp.gmail.com [php_network_getaddresses: getaddrinfo failed: Unknown host. # 0]". Does anyone know how to fix it ??? thanks in advance ...

'mailer' => [
        'class' => 'yii\swiftmailer\Mailer',
        // 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' => '[email protected]',
            'password' => '******',
            'port' => '587',
            'encryption' => 'tls',
        ],
    ],
    
asked by Carli 27.03.2018 в 18:03
source

0 answers