HostGator, Laravel and Email

Viewed 3075

I am configuring my Laravel app to send a welcome email, just like Jeffrey Way said at Laracasts and it works fine in Mailtrap. But when I change to HostGator, which I will use in real world, it just not work at all!

Here's some code:

MAIL_DRIVER=sendmail
MAIL_HOST=srv218.prodns.com.br
MAIL_PORT=465
MAIL_USERNAME=automatico@cepcar.com.br
MAIL_PASSWORD=******* <- obviously hidden
MAIL_ENCRYPTION=tls

Have changed the driver to SMTP, encryption to SSL, none but got no success. And the problem is that there are NO ERRORS to debug!

2 Answers

The following changes should solve your issue.

  1. Set a mail from address which is same as MAIL_USERNAME.
  2. Change your mail driver to smtp.
  3. Change mail encryption to ssl.

    MAIL_DRIVER=smtp
    MAIL_HOST=srv218.prodns.com.br
    MAIL_PORT=465
    MAIL_USERNAME=automatico@cepcar.com.br
    MAIL_PASSWORD=*******
    MAIL_ENCRYPTION=ssl
    MAIL_FROM_ADDRESS=automatico@cepcar.com.br
    
    

the best solution is to make the following configuration in the .env file in hostgator to be able to send the emails with the corporate emails you have to define your domain on the host

MAIL_HOST= mail.<tu_dominio> => mail.amazonventas.com

MAIL_PORT=465 => estatico

MAIL_MAILER=smtp
MAIL_HOST=mail.amazonventas.com 
MAIL_PORT=465
MAIL_USERNAME=**********@amazonventas.com
MAIL_PASSWORD="*********"
MAIL_ENCRYPTION=ssl
MAIL_FROM_ADDRESS=********@amazonventas.com
MAIL_FROM_NAME="${APP_NAME}"
MAIL_DRIVER=mailgun
Related