Ticket #23291: 23291.2.diff
File 23291.2.diff, 5.0 KB (added by , 12 years ago) |
---|
-
wp-admin/includes/upgrade.php
276 276 http://wordpress.org/ 277 277 "), $blog_url, $name, $password); 278 278 279 @wp_mail($email, __('New WordPress Site'), $message);279 wp_mail( $email, __( 'New WordPress Site' ), $message ); 280 280 } 281 281 endif; 282 282 -
wp-includes/pluggable.php
209 209 * @param string $message Message contents 210 210 * @param string|array $headers Optional. Additional headers. 211 211 * @param string|array $attachments Optional. Files to attach. 212 * @return bool Whether the email contents were sent successfully. 212 * @param string $return Optional. 'bool' to return boolean false on error, 'wp_error' to return a WP_Error object. Defaults to 'bool' 213 * @return bool|WP_Error Boolean true if the email was sent successfully. Boolean false or WP_Error if sending failed. WP_Error if email was sent, but with errors. 213 214 */ 214 function wp_mail( $to, $subject, $message, $headers = '', $attachments = array() ) { 215 function wp_mail( $to, $subject, $message, $headers = '', $attachments = array(), $return = 'bool' ) { 216 $errors = new WP_Error(); 217 215 218 // Compact the input, apply the filters, and extract them back out 216 219 extract( apply_filters( 'wp_mail', compact( 'to', 'subject', 'message', 'headers', 'attachments' ) ) ); 217 220 … … 356 359 } 357 360 $phpmailer->AddAddress( $recipient, $recipient_name); 358 361 } catch ( phpmailerException $e ) { 362 $errors->add( 'mailer_add_address', $e->getMessage() ); 359 363 continue; 360 364 } 361 365 } … … 378 382 } 379 383 $phpmailer->AddCc( $recipient, $recipient_name ); 380 384 } catch ( phpmailerException $e ) { 385 $errors->add( 'mailer_add_cc', $e->getMessage() ); 381 386 continue; 382 387 } 383 388 } … … 396 401 } 397 402 $phpmailer->AddBcc( $recipient, $recipient_name ); 398 403 } catch ( phpmailerException $e ) { 404 $errors->add( 'mailer_add_bcc', $e->getMessage() ); 399 405 continue; 400 406 } 401 407 } … … 439 445 try { 440 446 $phpmailer->AddAttachment($attachment); 441 447 } catch ( phpmailerException $e ) { 448 $errors->add( 'mailer_add_attachment', $e->getMessage() ); 442 449 continue; 443 450 } 444 451 } … … 450 457 try { 451 458 $phpmailer->Send(); 452 459 } catch ( phpmailerException $e ) { 453 return false; 460 $errors->add( 'mailer_send', $e->getMessage() ); 461 462 if ( 'wp_error' == $return ) 463 return $errors; 464 else 465 return false; 454 466 } 455 467 456 return true; 468 if ( 'wp_error' == $return && count( $errors->get_error_codes() > 0 ) ) 469 return $errors; 470 else 471 return true; 457 472 } 458 473 endif; 459 474 … … 1075 1090 $subject = apply_filters('comment_notification_subject', $subject, $comment_id); 1076 1091 $message_headers = apply_filters('comment_notification_headers', $message_headers, $comment_id); 1077 1092 1078 @wp_mail( $author->user_email, $subject, $notify_message, $message_headers );1093 wp_mail( $author->user_email, $subject, $notify_message, $message_headers ); 1079 1094 1080 1095 return true; 1081 1096 } … … 1158 1173 $message_headers = apply_filters('comment_moderation_headers', $message_headers); 1159 1174 1160 1175 foreach ( $email_to as $email ) 1161 @wp_mail($email, $subject, $notify_message, $message_headers);1176 wp_mail( $email, $subject, $notify_message, $message_headers ); 1162 1177 1163 1178 return true; 1164 1179 } … … 1208 1223 $message .= sprintf(__('Username: %s'), $user_login) . "\r\n\r\n"; 1209 1224 $message .= sprintf(__('E-mail: %s'), $user_email) . "\r\n"; 1210 1225 1211 @wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration'), $blogname), $message);1226 wp_mail( get_option( 'admin_email' ), sprintf( __( '[%s] New User Registration' ), $blogname ), $message ); 1212 1227 1213 1228 if ( empty($plaintext_pass) ) 1214 1229 return; -
wp-login.php
247 247 $title = apply_filters('retrieve_password_title', $title); 248 248 $message = apply_filters('retrieve_password_message', $message, $key); 249 249 250 if ( $message && !wp_mail($user_email, $title, $message) ) 251 wp_die( __('The e-mail could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function...') ); 250 if ( $message ) { 251 $mail_status = wp_mail( $user_email, $title, $message, '', array(), 'wp_error' ); 252 253 // mailer_send indicates the messages wasn't sent. Other error codes indicate the message was sent even though errors occurred. 254 if ( is_wp_error( $mail_status ) && in_array( 'mailer_send', $mail_status->get_error_codes() ) ) { 255 $mail_error_messages = implode( ". ", $mail_status->get_error_messages() ); 256 wp_die( __( 'The e-mail could not be sent.' ) . "<br />\n" . sprintf( __( '<strong>ERROR</strong>: %s' ), $mail_error_messages ) ); 257 } 258 } 259 else { 260 $errors->add( 'message_empty', __( '<strong>ERROR</strong>: Message was empty.' ) ); 261 return $errors; 262 } 252 263 253 264 return true; 254 265 }