Skip to content

Instantly share code, notes, and snippets.

@cmaas
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cmaas/767e7eba0ca705655119 to your computer and use it in GitHub Desktop.
Save cmaas/767e7eba0ca705655119 to your computer and use it in GitHub Desktop.
Laravel 4 – Mail from address with multiple domains

Send mails in Laravel 4 and configure "From" for multiple domains

In app/config/mail.php set the line with "from" to the following:

    'from' => array('address' => 'info@' . str_replace('www.', '', Request::getHost()), 'name' => 'Yourname'),

Use Request::getHost() for the whole domain (includes www if applicable). Request::getHttpHost() also includes the port number, Request::root() includes the protocol as well.

You can remove the str_replace() if your domain doesn't contain www.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment