diff --git a/wp-mail.php b/wp-mail.php index 7e046370f4..e5100558d1 100644 --- a/wp-mail.php +++ b/wp-mail.php @@ -60,10 +60,14 @@ for ($i=1; $i <= $count; $i++) : $subject = $subject[0]; } - // Set the author using the email address (To or Reply-To, the last used) + // Set the author using the email address (From or Reply-To, the last used) // otherwise use the site admin if ( preg_match('/(From|Reply-To): /', $line) ) { - $author = sanitize_email(preg_replace('/(From|Reply-To): /', '', $line)); + if ( preg_match('|[a-z0-9_.-]+@[a-z0-9_.-]+(?!.*<)|i', $line, $matches) ) + $author = $matches[0]; + else + $author = trim($line); + $author = sanitize_email($author); if ( is_email($author) ) { echo "Author = {$author}

"; $author = $wpdb->escape($author);