Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Amalmax's avatar

send emails with gmail in Laravel

Hi, I am going to send emails using gmail smtp from My app to My collaborators. I am working in localhost with WAMP Server. I need free email sending option. plz give me good reference or tutorials links.

0 likes
15 replies
SmoDav's avatar

How many emails do you project per month? If it's not very high you can check out Sparkpost

1 like
Amalmax's avatar

@mstnorris I tried Mailgun but problem was it asked domain like (www.somename.com) but I am developing in My localhost

mstnorris's avatar

Ahh I see, that isn't an issue as you can test emails with a few "verified" email addresses that you own. And then... when you're ready to push it to production, you just verify your real domain like www.somename.com and you're good to go!

Amalmax's avatar

if I use gmail smpt, am I need any email sending provides like Mailgun,Mandril,Sendgrid?

mstnorris's avatar

No. Just use your Gmail username (email address) and your password. Just don't store them directly in the config/mail.php file. Store them as environment variables in your .env file.

1 like
undrwd's avatar

Give SparkPost.com a try, they have a free plan well above 1k/mo. When you set it up you will need a domain but you can use any domain for testing. You don't have to validate through an [email protected] . Just click to go to dashboard and setup the spf and dkim txt records by changing those where your domain's DNS is. (registrar or cloudflare for my projects).

Once you have that setup create an API key in spark post just check Transmissions: Read/Write and leave allowed IP blank for your local dev env. For production create a new one and enter your server IP.

This has more info. https://mattstauffer.co/blog/using-sparkpost-for-transactional-emails-with-laravel

Also you can set your emal drive to log on development and it still store your emails in your log file, if you're just testing.

1 like
Amalmax's avatar
Amalmax
OP
Best Answer
Level 4

if any one use gmail smtp they can follow this way simply first go to https://myaccount.google.com/security#connectedapps and Take a look at the Sign-in & security -> Connected apps & sites -> Allow less secure apps settings. You must turn the option "Allow less secure apps" ON.

then edit your .env as follows

MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=yourEmail
MAIL_PASSWORD=yourPassword
MAIL_ENCRYPTION=tls

Well done! You're now ready to send emails using Gmail!

2 likes
malambart's avatar

@Amalmax I've tried these exact settings on my homestead (version 0.4.1) local machine and I turned on the setting "Allow less secure apps". I also tried pretty much all I could find over the web, but still, still, I get this annoying message when I try to get the password reset link by email:

"Connection could not be established with host smtp.gmail.com"

I'm using Laravel 5.3.

Please save my day :-)

malambart's avatar

Absolutely. But I gave up and used MailGun instead.

Amalmax's avatar

@malambart I did not any experience with MailGun. can't you use gmail as email client?

Devpat's avatar

my email successfully sent but i did not receive it on my gmail account.

Mego's avatar

Hello there. I tried to set an e-mail on WAMP by your orders, but it doesn't work :( I still get an error

Swift_TransportException Expected response code 250 but got code "530", with message "530 5.7.1 Authentication required "

Did some change during ages?

Please or to participate in this conversation.