By default, all email sent from your site uses the site email address configured at
admin/settings/site-information as the “from” address. On most sites this is set to something generic, like “email@example.com” or “firstname.lastname@example.org”. However in a lot of mail clients, when the email reaches your inbox, it appears as being just from “webmaster” or “noreply”. Wouldn’t it be better if it appeared as being from “Your site” or whatever you have set your site name to be?
You can achieve this easily with just a few lines of code in a custom module:
* Implements hook_mail_alter().
The above function retrieves the site name and email address that you configured on
admin/settings/site-information. Then for each email sent from the site, if the “from” email address matches the site address, it modifies the From header to include the site name as well. This produces the nice user-friendly effect where emails in your inbox appear to be from “Your site” rather than just “webmaster”.