diff options
| author | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2007-02-26 14:03:58 +0000 |
|---|---|---|
| committer | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2007-02-26 14:03:58 +0000 |
| commit | ce8693de30e8da06a8a4982e321f0a33fbeee979 (patch) | |
| tree | c80ea3a19e84d0da5a48815fe4457e46f784e193 /wp-includes/pluggable.php | |
| parent | 132f53ddaeb250222a4ac85ebc0bf4dd780db60e (diff) | |
| download | wordpress-mu-ce8693de30e8da06a8a4982e321f0a33fbeee979.tar.gz wordpress-mu-ce8693de30e8da06a8a4982e321f0a33fbeee979.tar.xz wordpress-mu-ce8693de30e8da06a8a4982e321f0a33fbeee979.zip | |
WP Merge to rev 4950
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@900 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-includes/pluggable.php')
| -rw-r--r-- | wp-includes/pluggable.php | 57 |
1 files changed, 54 insertions, 3 deletions
diff --git a/wp-includes/pluggable.php b/wp-includes/pluggable.php index 9815607..67f17a9 100644 --- a/wp-includes/pluggable.php +++ b/wp-includes/pluggable.php @@ -162,13 +162,65 @@ endif; if ( !function_exists('wp_mail') ) : function wp_mail($to, $subject, $message, $headers = '') { - if( $headers == '' ) { + global $phpmailer; + + if ( !is_object( $phpmailer ) ) { + require_once(ABSPATH . WPINC . '/class-phpmailer.php'); + require_once(ABSPATH . WPINC . '/class-smtp.php'); + $phpmailer = new PHPMailer(); + } + + $mail = compact('to', 'subject', 'message', 'headers'); + $mail = apply_filters('wp_mail', $mail); + extract($mail); + + if ( $headers == '' ) { $headers = "MIME-Version: 1.0\n" . "From: " . get_option('admin_email') . "\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n"; } - return @mail($to, $subject, $message, $headers); + $phpmailer->ClearAddresses(); + $phpmailer->ClearCCs(); + $phpmailer->ClearBCCs(); + $phpmailer->ClearReplyTos(); + $phpmailer->ClearAllRecipients(); + $phpmailer->ClearCustomHeaders(); + + $phpmailer->FromName = "WordPress"; + $phpmailer->AddAddress("$to", ""); + $phpmailer->Subject = $subject; + $phpmailer->Body = $message; + $phpmailer->IsHTML(false); + $phpmailer->IsMail(); // set mailer to use php mail() + + do_action_ref_array('phpmailer_init', array(&$phpmailer)); + + $mailheaders = (array) explode( "\n", $headers ); + foreach ( $mailheaders as $line ) { + $header = explode( ":", $line ); + switch ( trim( $header[0] ) ) { + case "From": + $from = trim( str_replace( '"', '', $header[1] ) ); + if ( strpos( $from, '<' ) ) { + $phpmailer->FromName = str_replace( '"', '', substr( $header[1], 0, strpos( $header[1], '<' ) - 1 ) ); + $from = trim( substr( $from, strpos( $from, '<' ) + 1 ) ); + $from = str_replace( '>', '', $from ); + } else { + $phpmailer->FromName = $from; + } + $phpmailer->From = trim( $from ); + break; + default: + if ( $line != '' && $header[0] != 'MIME-Version' && $header[0] != 'Content-Type' ) + $phpmailer->AddCustomHeader( $line ); + break; + } + } + + $result = @$phpmailer->Send(); + + return $result; } endif; @@ -222,7 +274,6 @@ function auth_redirect() { !wp_login($_COOKIE[USER_COOKIE], $_COOKIE[PASS_COOKIE], true)) || (empty($_COOKIE[USER_COOKIE])) ) { nocache_headers(); - wp_clearcookie(); wp_redirect(get_option('siteurl') . '/wp-login.php?action=auth&redirect_to=' . urlencode($_SERVER['REQUEST_URI'])); |
