SMTP Server Email Setting – Laravel

Following code is written inside .env file. By default following 2 info are not included in .env.

  • MAIL_FROM_NAME=
  • MAIL_FROM_ADDRESS=

But we can manually put inside .env so that the developer do not need to change another setting inside config/mail.php

MAIL_DRIVER=smtp
MAIL_HOST=servername.anyhosting.com
MAIL_PORT=465
MAIL_USERNAME=noreply@anydomain.com
MAIL_PASSWORD=secret
MAIL_ENCRYPTION=ssl
MAIL_FROM_ADDRESS=noreply@anydomain.com
MAIL_FROM_NAME="Global From Email"

Email address written at MAIL_FROM_ADDRESS is for global FROM email. So whenever developer did not include from() inside programme. Then this global address is used. Similarly global name applies to MAIL_FROM_NAME

Note:

Make sure MAIL_FROM_ADDRESS belongs to MAIL_HOST.

MAIL_HOST of server can be checked using following command inside the console of phpmyadmin

SHOW VARIABLES WHERE VARIABLE_NAME = ‘HOST’

Leave a Reply

Your email address will not be published. Required fields are marked *