Changeset 4946
- Timestamp:
- 02/25/2007 08:23:25 PM (18 years ago)
- Location:
- trunk/wp-includes
- Files:
-
- 2 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/pluggable.php
r4885 r4946 157 157 if ( !function_exists('wp_mail') ) : 158 158 function wp_mail($to, $subject, $message, $headers = '') { 159 if( $headers == '' ) { 159 global $phpmailer; 160 error_log("mailing $subject\n", 0); 161 if ( !is_object( $phpmailer ) ) { 162 require_once(ABSPATH . WPINC . '/class-phpmailer.php'); 163 require_once(ABSPATH . WPINC . '/class-smtp.php'); 164 $phpmailer = new PHPMailer(); 165 } 166 167 $mail = compact('to', 'subject', 'message', 'headers'); 168 $mail = apply_filters('wp_mail', $mail); 169 extract($mail); 170 171 if ( $headers == '' ) { 160 172 $headers = "MIME-Version: 1.0\n" . 161 173 "From: wordpress@" . preg_replace('#^www\.#', '', strtolower($_SERVER['SERVER_NAME'])) . "\n" . … … 163 175 } 164 176 165 return @mail($to, $subject, $message, $headers); 177 $phpmailer->ClearAddresses(); 178 $phpmailer->ClearCCs(); 179 $phpmailer->ClearBCCs(); 180 $phpmailer->ClearReplyTos(); 181 $phpmailer->ClearAllRecipients(); 182 $phpmailer->ClearCustomHeaders(); 183 184 $phpmailer->FromName = "WordPress"; 185 $phpmailer->AddAddress("$to", ""); 186 $phpmailer->Subject = $subject; 187 $phpmailer->Body = $message; 188 $phpmailer->IsHTML(false); 189 $phpmailer->IsMail(); // set mailer to use php mail() 190 191 do_action_ref_array('phpmailer_init', array(&$phpmailer)); 192 193 $mailheaders = (array) explode( "\n", $headers ); 194 foreach ( $mailheaders as $line ) { 195 $header = explode( ":", $line ); 196 switch ( trim( $header[0] ) ) { 197 case "From": 198 $from = trim( str_replace( '"', '', $header[1] ) ); 199 if ( strpos( $from, '<' ) ) { 200 $phpmailer->FromName = str_replace( '"', '', substr( $header[1], 0, strpos( $header[1], '<' ) - 1 ) ); 201 $from = trim( substr( $from, strpos( $from, '<' ) + 1 ) ); 202 $from = str_replace( '>', '', $from ); 203 } else { 204 $phpmailer->FromName = $from; 205 } 206 $phpmailer->From = trim( $from ); 207 break; 208 default: 209 if ( $line != '' && $header[0] != 'MIME-Version' && $header[0] != 'Content-Type' ) 210 $phpmailer->AddCustomHeader( $line ); 211 break; 212 } 213 } 214 215 $result = @$phpmailer->Send(); 216 error_log("mailing result $result\n", 0); 217 return $result; 166 218 } 167 219 endif;
Note: See TracChangeset
for help on using the changeset viewer.