{"id":88896,"date":"2012-07-25T13:00:19","date_gmt":"2012-07-25T17:00:19","guid":{"rendered":"http:\/\/wpmu.org\/?p=88896"},"modified":"2022-04-20T03:50:55","modified_gmt":"2022-04-20T03:50:55","slug":"wordpress-email-settings","status":"publish","type":"post","link":"https:\/\/wpmudev.com\/blog\/wordpress-email-settings\/","title":{"rendered":"Change WordPress Email &#8220;Send From&#8221; Settings"},"content":{"rendered":"<p>By default, your WordPress installation sends user registration emails from &#8220;wordpress@top-level-domain.com&#8221; For example, if your blog is at site.example.com, emails will come from wordpress@example.com.<\/p>\n<p>Continue reading, or jump ahead using these links:<\/p>\n<ul>\n<li><a href=\"#dont-want-to-use-the-default-wp-email\">I Don\u2019t Want to Use the Default WordPress Email<\/a><\/li>\n<li><a href=\"#screenshots\">Change WP eMail From Details Screenshots<\/a><\/li>\n<li><a href=\"#wp-email-settings\">WordPress Email Settings<\/a><\/li>\n<li><a href=\"#code\">The functions.php code<\/a><\/li>\n<li><a href=\"#customizing-the-email-content\">Customizing the Email Content<\/a><\/li>\n<\/ul>\n<h2 id=\"dont-want-to-use-the-default-wp-email\">I Don&#8217;t Want to Use the Default WordPress Email<\/h2>\n<p>If my real email address is cliff@example.com or businessname@gmail.com, I want my WordPress emails &#8220;branded&#8221; with my real email address.<\/p>\n<p>If you don&#8217;t want to <a href=\"https:\/\/wpmudev.com\/email-hosting\/\" target=\"_blank\" rel=\"noopener\">set up email hosting for your site<\/a>, the <a href=\"http:\/\/www.tipsandtricks-hq.com\/wordpress-plugin-change-wp-email-from-details-1883\" target=\"_blank\">Change WP eMail From Details<\/a> plugin is quick and easy to set up and does exactly what we want.<\/p>\n<p><em><strong>See the end of this post for a simple functions.php alternative, which is my preferred method<\/strong><\/em> because the Change WP eMail plugin isn&#8217;t from the WP Plugin Directory, and there are more files in the plugin&#8217;s folder than I would have expected necessary to achieve this functionality, plus some warnings from <a href=\"https:\/\/wpmudev.com\/blog\/wordpress-deprecated-function\/\" target=\"_blank\">the Plugin Check<\/a> plugin. I did verify both methods accomplish the stated goal &#8211; to customize the &#8220;from&#8221; email name and address.<\/p>\n<h2 id=\"screenshots\">Change WP eMail From Details Screenshots<\/h2>\n<p>The blank plugin settings screen, after initial installation:<\/p>\n<p><a rel=\"lightbox[88896]\" class=\"blog-thumbnail\" href=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2012\/07\/Change-WP-eMail-From-Details-screenshot.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-88978\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2012\/07\/Change-WP-eMail-From-Details-screenshot-1024x491.png\" alt=\"Post image\" aria-hidden=\"true\" width=\"685\" height=\"328\" \/><\/a><\/p>\n<p>The plugin settings screen with options filled out (courtesy of the plugin&#8217;s webpage):<\/p>\n<figure id=\"attachment_88979\" class=\"wp-caption aligncenter\" data-caption=\"true\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-88979\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2012\/07\/change-email-from-details-plugin-settings-sc.png\" alt=\"Post image\" aria-hidden=\"true\" width=\"638\" height=\"352\" \/><figcaption class=\"wp-caption-text\">Notice the checkboxes; they control the plugin&#8217;s operation.<\/figcaption><\/figure>\n<h2 id=\"wp-email-settings\">WordPress Email Settings<\/h2>\n<p>To be clear, the General Settings email address is used for <em>receiving<\/em>\u00a0administrator emails, not the setting for outgoing emails.<\/p>\n<p style=\"text-align: center;\"><a rel=\"lightbox[88896]\" class=\"blog-thumbnail\" href=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2012\/07\/WordPress-General-Settings-email-address.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-88983 aligncenter\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2012\/07\/WordPress-General-Settings-email-address.png\" alt=\"Post image\" aria-hidden=\"true\" width=\"653\" height=\"293\" \/><\/a><\/p>\n<h2 id=\"code\">The<em>\u00a0functions.php<\/em>\u00a0code<\/h2>\n<p>This is something you&#8217;d probably want out of your theme&#8217;s functions.php file and into a &#8220;functions plugin&#8221;. The code is the same, but use the plugin mentioned above (without these snippets), or use a <a href=\"https:\/\/wpmudev.com\/blog\/wordpress-code-snippets\/\" target=\"_blank\">functions<\/a> <a href=\"https:\/\/wpmudev.com\/blog\/how-to-create-your-own-super-simple-wordpress-plugins\/\" target=\"_blank\">plugin<\/a> instead of your theme&#8217;s functions.php file.<\/p>\n<h3>Change the email address<\/h3>\n<p>Here are 2 functions.php snippets (use one or the other) to change the &#8220;from email address&#8221;:<\/p>\n<h4>Option 1<\/h4>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n\/* enter the full email address you want displayed *\/\r\n\/* from http:\/\/miloguide.com\/filter-hooks\/wp_mail_from\/ *\/\r\nfunction xyz_filter_wp_mail_from($email){\r\nreturn &quot;daffy.duck@example.com&quot;;\r\n}\r\nadd_filter(&quot;wp_mail_from&quot;, &quot;xyz_filter_wp_mail_from&quot;);\r\n<\/pre>\n<h4>Option 2 (functionality not available in the plugin)<\/h4>\n<p>I like this one because it&#8217;s easier to add to new websites. I don&#8217;t want to accidentally use &#8220;me@lmnop.com&#8221; and then copy\/paste to my client at xyz.com and have their emails look like they&#8217;re coming from lmnop.com&#8217;s site. If you put &#8220;wordpress@&#8221; in this code, it&#8217;s basically duplicating what WordPress already does by default. So maybe use &#8220;contact@&#8221; and make sure that&#8217;s an address that your users can reply to. Or use &#8220;noreply@&#8221; to discourage reply emails.<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n\/* auto-detect the server so you only have to enter the front\/from half of the email address, including the @ sign *\/\r\nfunction xyz_filter_wp_mail_from($email){\r\n\/* start of code lifted from wordpress core, at http:\/\/svn.automattic.com\/wordpress\/tags\/3.4\/wp-includes\/pluggable.php *\/\r\n$sitename = strtolower( $_SERVER&#x5B;'SERVER_NAME'] );\r\nif ( substr( $sitename, 0, 4 ) == 'www.' ) {\r\n$sitename = substr( $sitename, 4 );\r\n}\r\n\/* end of code lifted from wordpress core *\/\r\n$myfront = &quot;whateverIwant@&quot;;\r\n$myback = $sitename;\r\n$myfrom = $myfront . $myback;\r\nreturn $myfrom;\r\n}\r\nadd_filter(&quot;wp_mail_from&quot;, &quot;xyz_filter_wp_mail_from&quot;);\r\n<\/pre>\n<h3>Change the Name<\/h3>\n<p>Here&#8217;s the snippet for changing the &#8220;from email name&#8221;:<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n\/* enter the full name you want displayed alongside the email address *\/\r\n\/* from http:\/\/miloguide.com\/filter-hooks\/wp_mail_from_name\/ *\/\r\nfunction xyz_filter_wp_mail_from_name($from_name){\r\nreturn &quot;Best Name Ever&quot;;\r\n}\r\nadd_filter(&quot;wp_mail_from_name&quot;, &quot;xyz_filter_wp_mail_from_name&quot;);\r\n<\/pre>\n<p>Your email recipients (like <a href=\"https:\/\/wpmudev.com\/blog\/create-a-custom-wordpress-registration-link-and-help-stop-spam\/\" target=\"_blank\">new member registrations<\/a> and <a href=\"https:\/\/wpmudev.com\/blog\/wordpress-diff-plugin-for-post-changes\/\" target=\"_blank\">post edit notifications<\/a>) will now see your plugin&#8217;s settings in action.<\/p>\n<figure id=\"attachment_88988\" class=\"wp-caption aligncenter\" data-caption=\"true\"><a rel=\"lightbox[88896]\" class=\"blog-thumbnail\" href=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2012\/07\/WordPress-from-name-and-from-email-address-screenshot.png\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-88988 \" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2012\/07\/WordPress-from-name-and-from-email-address-screenshot.png\" alt=\"Post image\" aria-hidden=\"true\" width=\"659\" height=\"230\" \/><\/a><figcaption class=\"wp-caption-text\">From &#8220;name&#8221; and &#8220;address&#8221; are highlighted by the red outlines<\/figcaption><\/figure>\n<h2 id=\"customizing-the-email-content\">Customizing the Email Content<\/h2>\n<p>So, we&#8217;ve looked at changing the From Name and Email Address and putting a template around the email content. But what about the content itself?<\/p>\n<p>Like me, you might think that this is fairly fundamental to running a site and that it should be available in the admin interface. The bad news is that the new registration (&#8216;welcome&#8217;) email, for example, is about as far removed from the admin interface as is possible, being deeply embedded in the pluggable.php file in the wp-includes folder. Definitely somewhere we don&#8217;t want to go editing.<\/p>\n<p>One other annoying aspect is that whilst the comment, trackback and pingback notifications all have filters applied to their subject and content, allowing them to be easily changed, the new user registration does not. Why there isn&#8217;t consistency across the emails only the WordPress gods know.<\/p>\n<p>The good news is that Sean Barton has done the heavy lifting for us and created his <a title=\"Read more about this plugin at the WordPress Plugin Repository\" href=\"http:\/\/wordpress.org\/plugins\/welcome-email-editor\/\" rel=\"noopener\" target=\"_blank\">SB Welcome Email Editor<\/a> which enables the editing of the content for the following emails:<\/p>\n<ul>\n<li>Welcome email to new user<\/li>\n<li>New user notification to Admin<\/li>\n<li>Forgot password (sent to the user)<\/li>\n<\/ul>\n<p>Install and activate the plugin and click on Settings &gt; SB Welcome Email. There are a number of options to complete here and again you can set the From Email Address and From Name. You can also set whether to send the emails in text or HTML format and, of course, set the subject and body for the emails listed above.<\/p>\n<figure id=\"attachment_123153\" class=\"wp-caption aligncenter\" data-caption=\"true\"><a rel=\"lightbox[88896]\" class=\"blog-thumbnail\" href=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2013\/11\/sb_welcome_email.jpg\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-123153\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2013\/11\/sb_welcome_email.jpg\" alt=\"Screenshot of the welcome email settings\" width=\"700\" height=\"511\" \/><\/a><figcaption class=\"wp-caption-text\">Make a good first impression with a more welcoming Welcome email<\/figcaption><\/figure>\n<p>As you can see from the above screenshot,\u00a0this plugin plays really nicely with the WP Better Email plugin so if you want to use both I would recommend the following settings for SB Welcome Email:<\/p>\n<ul>\n<li><strong>From Email Address<\/strong> &#8211; leave blank (use settings from WP Better Email)<\/li>\n<li><strong>From Name<\/strong> &#8211; leave blank (use settings from WP Better Email)<\/li>\n<li><strong>Send Email As<\/strong> &#8211; TEXT<\/li>\n<li><strong>Set Global Email Headers<\/strong> &#8211; No<\/li>\n<\/ul>\n<p>Keeping the emails as text means that WP Better Emails has no problems wrapping the content in its template and will also send out both an HTML and plain text version.<\/p>\n<p>It&#8217;s as simple as that. Feel free to share your own experiences below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>By default, your WordPress installation sends user registration emails from &#8220;wordpress@top-level-domain.com&#8221; For example, if your blog is at site.example.com, emails will come from wordpress@example.com. Continue reading, or jump ahead using these links: I Don\u2019t Want to Use the Default WordPress Email Change WP eMail From Details Screenshots WordPress Email Settings The functions.php code Customizing the [&hellip;]<\/p>\n","protected":false},"author":132061,"featured_media":207694,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"blog_reading_time":"","wds_primary_category":0,"wds_primary_tutorials_categories":0,"footnotes":""},"categories":[4],"tags":[106,778],"tutorials_categories":[],"class_list":["post-88896","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-plugins","tag-email","tag-functions"],"_links":{"self":[{"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/posts\/88896","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/users\/132061"}],"replies":[{"embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/comments?post=88896"}],"version-history":[{"count":11,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/posts\/88896\/revisions"}],"predecessor-version":[{"id":209307,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/posts\/88896\/revisions\/209307"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/media\/207694"}],"wp:attachment":[{"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/media?parent=88896"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/categories?post=88896"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/tags?post=88896"},{"taxonomy":"tutorials_categories","embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/tutorials_categories?post=88896"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}