You need to enter an actual email address to work with Google?
Sending an Email on Laravel 5
I want to send an email on L5. I have edited .env file correctly:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=username@gmail.com
MAIL_PASSWORD=mypassword
I'm using my Gmail a/c.
The above configurations give me this error message:
Swift_TransportException in AuthHandler.php line 181: Failed to authenticate on SMTP server with username "username@gmail.com" using 2 possible authenticators
How do I solve this?
Try with 2 step verification on and make an app for your Laravel app and use that new password.
Have you tried changing the port to 465?
@jcq126 That gives me Swift_TransportException in StreamBuffer.php line 265: Connection could not be established with host smtp.gmail.com [Connection timed out #110] error
@richard Is an encryption protocol set ?
'encryption' => 'tls' or 'encryption' => 'ssl'
Looking at https://support.google.com/mail/answer/78775?hl=en
"port 465 (with SSL) and port 587 (with TLS)"
I'm thinking that Google Mail services will only accept secured connections - https://support.google.com/a/answer/2520500?hl=en
Possibly worth checking Imap-SSL/Pop3-SSL server side.
@Steve_U I have tried this "port 465 (with SSL) and port 587 (with TLS)"
Restarted server.
Still nothing.
Is anyone here using gmail to send their mails? Please share the your config settings
I do but not in Laravel, just testing the settings in L5.
Edit
These work
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME=username@example.com
MAIL_PASSWORD=pass
mail.php
'encryption' => 'ssl',
Only one other thing I can think of, when I was using gmail before switching to Mandrill, I had to go into my gmail account and enable some kind of "accept less secure access applications" or something along those lines.
@richard if you look in your gmail account associated with this, you will find an email telling you that access was blocked.
Within that email is a link to a setting that you can change that allows less secure apps to have access.
Thats what I just said lol, hopefully it works for you.
I had to do a two step authentication with gmail.
@jcq126 yeah sorry about that, somehow I didn't see that and it was right under my nose lol.
Well, I have managed to send an email using @bashy's configurations on my local machine running Laravel's homestead. However, moving the files to my VPS, it cannot send. It throws Connection could not be established with host smtp.gmail.com [Connection timed out #110] error.
Can you ping or telnet to the SMTP server for gmail?
Hi @richard,
I had the same problem when I was setting up my Gmail to work with Laravel 5. I had to do what @jcq126 suggested https://support.google.com/accounts/answer/6010255?hl=en
Also, I had to 'train' Google by visiting the following link https://accounts.google.com/DisplayUnlockCaptcha if it didn't work. Eventually Google decided that I was allowed and let me through automatically.
For ref, my env:
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=username@gmail.com
MAIL_PASSWORD=password
Make sure the port is open on your server. 465 or 587 - whichever you have used.
@bashy I have ping'd it. Shows there is a valid communication. @desloc I have allowed access to less secure apps and clicked the second link... but am still unable to send an email @sitesense How do I 'open' the port? lol... Or how do I check if a port is open or not.
I have signed up on Mandrill.
MAIL_DRIVER=mandrill
MAIL_HOST=smtp.mandrillapp.com
MAIL_PORT=587
MAIL_USERNAME=username@gmail.com
MAIL_PASSWORD=myapikey
I got an error FatalErrorException in MandrillTransport.php line 114: Class 'GuzzleHttp\Client' not found
@richard if you can ping it then you don't need to open the port... you did ping it from the server and not your local machine right?
Yaaay! I have managed to solve it using these settings
MAIL_DRIVER=mail
MAIL_HOST=smtp.mandrillapp.com
MAIL_PORT=587
MAIL_USERNAME=username@gmail.com
MAIL_PASSWORD=myapikey
though they are sending mails to my spam folder :(
@sitesense thanks for your help
I would go as far to telnet into the SMTP server so you can see the HELO response, that way you know it's connectable. Make sure to do what @sitesense said above. Server -> Gmail.
For the mandrill API you need Guzzle/http package.
"guzzlehttp/guzzle": "~5.0"
@bashy @sitesense I pinged it from the server (via Windows - puTTy SSH). I just cant figure out what's wrong with Gmail. Can we now configure Mandrill to send mails to Inbox and not Spam folder?
Mainly SPF records etc to "sign" the emails to verify that they came from the domain.
On the Gmail matter, who knows. You'd have to try a telnet to make sure you can connect on the other port. A ping alone won't confirm that.

@bashy telnet command is not defined http://d.pr/i/1j4jO/2Q703vzd [lol, how do you attach a pic on laracasts]
Depends what OS the server is and if it's installed but I think it's
sudo apt-get install telnetd
For embedding images, do

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mandrillapp.com
MAIL_PORT=587
ENCRYPTION=tls
MAIL_USERNAME=username@gmail.com
MAIL_PASSWORD=myapikey
It is Working fine in my localhost but i got error "Connection could not be established with host smtp.mandrillapp.com" on server.
@richard If the problem is from Gmail, you can not send email in localhost. My app can send from localhost but it can't after I upload onto server. I think the problem is from server.
I got that problem till now :(
Please or to participate in this conversation.