From ea903eba7e28fdc1744735ed290956275edf8256 Mon Sep 17 00:00:00 2001 From: westi Date: Sun, 15 Feb 2009 13:31:43 +0000 Subject: [PATCH] Add documentation to detail reasoning for default from address. See #5007 props pishmishy git-svn-id: http://svn.automattic.com/wordpress/trunk@10575 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/upgrade.php | 3 +-- wp-includes/pluggable.php | 10 ++++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/wp-admin/includes/upgrade.php b/wp-admin/includes/upgrade.php index 7042f2c2a..dbd52bdd1 100644 --- a/wp-admin/includes/upgrade.php +++ b/wp-admin/includes/upgrade.php @@ -159,7 +159,6 @@ function wp_new_blog_notification($blog_title, $blog_url, $user_id, $password) { $user = new WP_User($user_id); $email = $user->user_email; $name = $user->user_login; - $message_headers = 'From: "' . $blog_title . '" '; $message = sprintf(__("Your new WordPress blog has been successfully set up at: %1\$s @@ -175,7 +174,7 @@ We hope you enjoy your new blog. Thanks! http://wordpress.org/ "), $blog_url, $name, $password); - @wp_mail($email, __('New WordPress Blog'), $message, $message_headers); + @wp_mail($email, __('New WordPress Blog'), $message); } endif; diff --git a/wp-includes/pluggable.php b/wp-includes/pluggable.php index 84511f33a..fc6fc8ff8 100644 --- a/wp-includes/pluggable.php +++ b/wp-includes/pluggable.php @@ -328,7 +328,13 @@ function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() $from_name = 'WordPress'; } - // If we don't have an email from the input headers + /* If we don't have an email from the input headers default to wordpress@$sitename + * Some hosts will block outgoing mail from this address if it doesn't exist but + * there's no easy alternative. Defaulting to admin_email might appear to be another + * option but some hosts may refuse to relay mail from an unknown domain. See + * http://trac.wordpress.org/ticket/5007. + */ + if ( !isset( $from_email ) ) { // Get the site domain and get rid of www. $sitename = strtolower( $_SERVER['SERVER_NAME'] ); @@ -339,7 +345,7 @@ function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() $from_email = 'wordpress@' . $sitename; } - // Set the from name and email + // Plugin authors can override the potentially troublesome default $phpmailer->From = apply_filters( 'wp_mail_from', $from_email ); $phpmailer->FromName = apply_filters( 'wp_mail_from_name', $from_name );