'SMTP Time out error - Send email from localhost

I tried to send email using Google SMTP from localhost, but I keep getting the SMTP time out. error. This is my config:

'EmailTransport' => [
        'default' => [
            'className' => 'Smtp',
            // The following keys are used in SMTP transports
            'host' => 'tls://smtp.gmail.com',
            'port' => 587,
            'username' => '[email protected]',
            'password' => 'xxxxxsecret',
            'log' => true,
            'tls' => true,
            'domain' => 'localhost',
        ],
    ],

I'm running my app on Wampp server.

Please help me, thank you in advanced!



Solution 1:[1]

Using mailtrap, you can test this locally. If this works, then most likely the configuration is incorrect or the email isn't being sent through google mail.

https://mailtrap.io - create account and use for free.

'EmailTransport' => [
    'default' => [
        'className' => 'Smtp',
        'host' => 'smtp.mailtrap.io',
        'port' => 2525,
        'timeout' => 30,
        'username' => 'YOUR_USERNAME',
        'password' => 'YOUR_PASSWORD',
        'client' => null,
        'tls' => true,
        'url' => env('EMAIL_TRANSPORT_DEFAULT_URL', null),
    ],
],

You can also change the port from 587 to 465 and check. Allow Google to trust your local email server.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 dekts