0

I have a laravel application hosted on heroku using sendgrid add-on for smtp functionality. Within my app I have a register form which sends a email notification once a user has registered but I get these error everytime I try registering:

(1/1) Swift_TransportException Connection could not be established with host smtp.sendgrid.net :stream_socket_client(): php_network_getaddresses: getaddrinfo failed: Name or service not known

I have triple checked my config settings for mail, the settings for mail smtp I use are:

MAIL_DRIVER=smtp
MAIL_HOST=smtp.sendgrid.net
MAIL_PORT=587
MAIL_USERNAME=secret
MAIL_PASSWORD=secret
MAIL_ENCRYPTION=tls

I have added these to Heroku's var information and still no luck.

1 Answers1

0

Try to change

MAIL_DRIVER=smtp

to

MAIL_DRIVER=sendmail
Doro
  • 347
  • 2
  • 6
  • Hello thanks for this tried this and I thought it worked for a second but now I get this error: (1/1) ErrorException fwrite(): write of 348 bytes failed with errno=32 Broken pipe – DalvinderpalDevelopment May 08 '20 at 12:50
  • Try to clear config by running the command `php artisan config:clear` – Doro May 08 '20 at 13:20
  • Hi there, Ive trying using php artisan config:clear and then pushing the changes to heroku and although I dont get this error I now get: (1/1) Swift_TransportException Expected response code 220 but got an empty response – DalvinderpalDevelopment May 08 '20 at 13:36
  • ok check this out https://stackoverflow.com/questions/32693528/expected-response-code-220-but-got-code-with-message-in-laravel I hope this helps – Doro May 08 '20 at 13:44
  • Hi, thanks for the link. I think the information is more inline if people are using google instead of sendgrid, its just fustrtaing as I had the laravel application hosted on heroku a year ago with sendgrid and was working fine then but for some reason when hosting again its not working. my mail config setting are: MAIL_DRIVER=sendmail MAIL_HOST=smtp.sendgrid.net MAIL_PORT=587 MAIL_USERNAME=secret MAIL_PASSWORD=secret MAIL_ENCRYPTION=tls – DalvinderpalDevelopment May 08 '20 at 13:55
  • With MAIL_USERNAME and MAIL_PASSWORD being sendgrid's smtp relay api settings so im using a api key – DalvinderpalDevelopment May 08 '20 at 13:55
  • the sendmail system path is: 'sendmail' => '/usr/sbin/sendmail -bs', – DalvinderpalDevelopment May 08 '20 at 13:56
  • Are you trying to send mail from localhost? currently on Laravel sending mail from localhost can only be sent to mailtrap. You can only send when it is hosted. but you can test you work with mailtrap.io before hosting – Doro May 08 '20 at 13:59
  • Hi, I have the laravel app hosted locally and I use google smtp settings and works fine, but I have it hosted on heroku and have to use heroku mail add-ons such as sendgrid – DalvinderpalDevelopment May 08 '20 at 14:01