Last active
August 29, 2015 14:28
-
-
Save coquer/51c83ee846d8035f812c to your computer and use it in GitHub Desktop.
Change default sender email address wordpress, This includes email being sent from a subdomains.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function setDefaultFromEmail(){ | |
| $url = ""; | |
| $parse = parse_url(home_url()); | |
| if (strpos($parse['host'], 'www') !== false) { | |
| $url = preg_replace('#^www\.(.+\.)#i', '$1', $parse['host']); | |
| }else{ | |
| $url = $parse['host']; | |
| } | |
| $array = explode(".", $url); | |
| $uri = (array_key_exists(count($array) - 2, $array) ? $array[count($array) - 2] : "").".".$array[count($array) - 1]; | |
| return "no-reply@" . $uri; | |
| } | |
| add_filter('wp_mail_from', 'setDefaultFromEmail'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment