Ticket #23291: 23291.4.diff
File 23291.4.diff, 5.0 KB (added by , 12 years ago) |
---|
-
wp-login.php
263 263 $title = apply_filters('retrieve_password_title', $title); 264 264 $message = apply_filters('retrieve_password_message', $message, $key); 265 265 266 if ( $message && !wp_mail($user_email, $title, $message) )267 wp_die( __('The e-mail could not be sent.') . "<br />\n" . __('Possible reason: your host may have disabled the mail() function.'));266 if ( $message ) { 267 $mail_status = wp_mail( $user_email, $title, $message, '', array(), true ); 268 268 269 // mailer_send indicates the messages wasn't sent. Other error codes indicate the message was sent even though errors occurred. 270 if ( is_wp_error( $mail_status ) && in_array( 'mailer_send', $mail_status->get_error_codes() ) ) { 271 $mail_error_messages = implode( ". ", $mail_status->get_error_messages() ); 272 wp_die( __( 'The e-mail could not be sent.' ) . "<br />\n" . sprintf( __( '<strong>ERROR</strong>: %s' ), $mail_error_messages ) ); 273 } 274 } else { 275 $errors->add( 'message_empty', __( '<strong>ERROR</strong>: Message was empty.' ) ); 276 return $errors; 277 } 278 269 279 return true; 270 280 } 271 281 -
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 $wp_error Optional. false to return boolean false on error, true to return a WP_Error object. Defaults to false. 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(), $wp_error = false ) { 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 } … … 448 455 449 456 // Send! 450 457 try { 451 return $phpmailer->Send(); 458 $mail_status = $phpmailer->Send(); 459 460 if ( true == $wp_error && count( $errors->get_error_codes() ) > 0 ) { 461 return $errors; 462 } else { 463 return $mail_status; 464 } 452 465 } catch ( phpmailerException $e ) { 453 return false; 466 $errors->add( 'mailer_send', $e->getMessage() ); 467 468 if ( true == $wp_error ) { 469 return $errors; 470 } else { 471 return false; 472 } 454 473 } 455 474 } 456 475 endif; … … 1073 1092 $subject = apply_filters('comment_notification_subject', $subject, $comment_id); 1074 1093 $message_headers = apply_filters('comment_notification_headers', $message_headers, $comment_id); 1075 1094 1076 @wp_mail( $author->user_email, $subject, $notify_message, $message_headers );1095 wp_mail( $author->user_email, $subject, $notify_message, $message_headers ); 1077 1096 1078 1097 return true; 1079 1098 } … … 1156 1175 $message_headers = apply_filters('comment_moderation_headers', $message_headers); 1157 1176 1158 1177 foreach ( $email_to as $email ) 1159 @wp_mail($email, $subject, $notify_message, $message_headers);1178 wp_mail( $email, $subject, $notify_message, $message_headers ); 1160 1179 1161 1180 return true; 1162 1181 } … … 1203 1222 $message .= sprintf(__('Username: %s'), $user->user_login) . "\r\n\r\n"; 1204 1223 $message .= sprintf(__('E-mail: %s'), $user->user_email) . "\r\n"; 1205 1224 1206 @wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration'), $blogname), $message);1225 wp_mail( get_option( 'admin_email' ), sprintf( __( '[%s] New User Registration' ), $blogname ), $message ); 1207 1226 1208 1227 if ( empty($plaintext_pass) ) 1209 1228 return; -
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