Umut Savas
Umut Savas

Reputation: 113

Emails sent using SMTP Gmail don't get delivered

I'm trying to send mails from my webserver using Laravel 6 like this:

Mail::send('feedback', ['email' => $email, 'text' => $text], function($message) use ($receiver)
        {
            $message->to($receiver, 'The receiver')->subject('New Feedback');
        });

I added my login information into my .env file according to this page from google:

https://support.google.com/mail/answer/7126229?hl=de

my .env file:

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

but my mails don't get sent/delivered. I don't get any error message or anything logged. Everything seems to be working, but for some reason they don't get delivered.

I tried it with enabling insecure apps in my gmail settings and using my gmail password and also with creating an app password and using the app password. Both options didn't work.

Does someone have an idea what I'm doing wrong?

Upvotes: 0

Views: 117

Answers (2)

P. K. Tharindu
P. K. Tharindu

Reputation: 2730

Try changing .env variables as below:

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=username
MAIL_PASSWORD=password
MAIL_ENCRYPTION=tls

or

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME=username
MAIL_PASSWORD=password
MAIL_ENCRYPTION=ssl

Upvotes: 1

Zahid Nazir Khan
Zahid Nazir Khan

Reputation: 1

You should set the .env attribute as below

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=username
MAIL_PASSWORD=password
MAIL_ENCRYPTION=tls

Give it a try.

Upvotes: 0

Related Questions