Search code examples
laravelemailgmail

Not Getting Email using Gmail smtp on live server Laravel


I am on Laravel 5.6 and my application working well. I am using Gmail SMTP for mail services.

here is my .env file.

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
[email protected]
MAIL_PASSWORD=password
MAIL_ENCRYPTION=tls

I have already Turned ON Less secure apps in Gmail also turned ON 2 step verification.

From localhost, the mail system working like charm and I am getting all emails from Gmail SMTP.

But From Live Server, I am not getting any Emails and even there is no error popup.

My Host is a 000webhost free account because I am testing my Application.
so I read forums in 000webhost and change "SET MX RECORD " to "GOOGLE'S MX RECORD".

Now I am getting this error while sending any mail.

Expected response code 250 but got code "530", with message "530-5.5.1 Authentication Required. Learn more at 530 5.5.1 https://support.google.com/mail/?p=WantAuthError k142sm4568022ywa.67 - gsmtp "

Please help! Thanks in advance.


Solution

  • try changing your config/mail.php to your current credentials:

    'driver' => env('MAIL_DRIVER', 'smtp'),
    'host' => env('MAIL_HOST', 'smtp.gmail.com'),
    'port' => env('MAIL_PORT', 587),
    'encryption' => env('MAIL_ENCRYPTION', 'tls'),
    'username' => env('MAIL_USERNAME', '[email protected]'),
    'password' => env('MAIL_PASSWORD', 'password'),