In this post I'm going through a couple of problems that I've faced while trying to send emails from my web application hosted on Google Cloud (Compute engine), the Laravel version that I'm using is 4.2 .
Apparently, Google Cloud supports only port 587 by default for outgoing mail, maybe because port 465 is legacy now.
Here's the Stack Overflow link for you:
http://stackoverflow.com/questions/15796530/what-is-the-difference-between-ports-465-and-587
Solution: Use 587 as the port.
Swift_TransportException:
Expected response code 250 but got code "", with message ""
This Exception was thrown because the port that was used was 465 instead of 587.Apparently, Google Cloud supports only port 587 by default for outgoing mail, maybe because port 465 is legacy now.
Here's the Stack Overflow link for you:
http://stackoverflow.com/questions/15796530/what-is-the-difference-between-ports-465-and-587
Solution: Use 587 as the port.
Swift_TransportException:
Expected response code 250 but got code "535", with message "535-5.7.8 Username and Password not accepted. Learn more at...
This error is sent by Google refusing to log in to your account from an untrusted app (yours :D ).
Solution: Enable two-step verification for your google account (the one that's used to send the emails in your web app).
if you haven't already, go to https://www.google.com/landing/2step/ and hit "Get started" button and follow the instructions to set it up.
- After everything is set up, open "App-specific passwords" tab.
- click "Manage application-specific passwords".
- From there, open the "select app" select box and choose "Other".
- Type a descriptive name for you app and hit "Generate".
- You'll be given a password, copy that to your Laravel mail configuration file (config/mail.php) in the password entry and you're good to go.
Here's how the configuration file looks like
return
array
(
'driver'
=>
'smtp'
,
'host'
=>
'smtp.gmail.com'
,
'port'
=> 587,
'encryption'
=>
'tls'
,
'username'
=>
'your_gmail_username'
,
'password'
=>
'your_generated_password'
,
'sendmail'
=>
'/usr/sbin/sendmail -bs'
,
'pretend'
=> false,
);
That's it, your app should now be able to send emails without problems.
No comments:
Post a Comment