Improve the parsing of email addresses in wp_mail to re-support RFC2822 nameless "<address@tld.com>" style. Fixes #18463 props kitchin and SergeyBiryukov.

git-svn-id: https://develop.svn.wordpress.org/trunk@18717 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Peter Westwood 2011-09-19 14:30:50 +00:00
parent 442590c211
commit d01e2af94b
1 changed files with 6 additions and 6 deletions

View File

@ -338,13 +338,13 @@ function wp_mail( $to, $subject, $message, $headers = '', $attachments = array()
try {
// Break $recipient into name and address parts if in the format "Foo <bar@baz.com>"
$recipient_name = '';
if( preg_match( '/(.+)\s?<(.+)>/', $recipient, $matches ) ) {
if( preg_match( '/(.*)<(.+)>/', $recipient, $matches ) ) {
if ( count( $matches ) == 3 ) {
$recipient_name = $matches[1];
$recipient = $matches[2];
}
}
$phpmailer->AddAddress( trim( $recipient ), $recipient_name);
$phpmailer->AddAddress( $recipient, $recipient_name);
} catch ( phpmailerException $e ) {
continue;
}
@ -360,13 +360,13 @@ function wp_mail( $to, $subject, $message, $headers = '', $attachments = array()
try {
// Break $recipient into name and address parts if in the format "Foo <bar@baz.com>"
$recipient_name = '';
if( preg_match( '/(.+)\s?<(.+)>/', $recipient, $matches ) ) {
if( preg_match( '/(.*)<(.+)>/', $recipient, $matches ) ) {
if ( count( $matches ) == 3 ) {
$recipient_name = $matches[1];
$recipient = $matches[2];
}
}
$phpmailer->AddCc( trim($recipient), $recipient_name );
$phpmailer->AddCc( $recipient, $recipient_name );
} catch ( phpmailerException $e ) {
continue;
}
@ -378,13 +378,13 @@ function wp_mail( $to, $subject, $message, $headers = '', $attachments = array()
try {
// Break $recipient into name and address parts if in the format "Foo <bar@baz.com>"
$recipient_name = '';
if( preg_match( '/(.+)\s?<(.+)>/', $recipient, $matches ) ) {
if( preg_match( '/(.*)<(.+)>/', $recipient, $matches ) ) {
if ( count( $matches ) == 3 ) {
$recipient_name = $matches[1];
$recipient = $matches[2];
}
}
$phpmailer->AddBcc( trim($recipient), $recipient_name );
$phpmailer->AddBcc( $recipient, $recipient_name );
} catch ( phpmailerException $e ) {
continue;
}