[wp-trac] [WordPress Trac] #23291: wp_mail should handle phpmailer exceptions instead of ignoring them

WordPress Trac noreply at wordpress.org
Mon Jan 28 10:46:16 UTC 2013


#23291: wp_mail should handle phpmailer exceptions instead of ignoring them
-------------------------+------------------------------
 Reporter:  mark-k       |       Owner:
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  Mail         |     Version:  3.5
 Severity:  minor        |  Resolution:
 Keywords:  has-patch    |
-------------------------+------------------------------

Comment (by mark-k):

 Replying to [comment:19 iandunn]:
 > I updated the patch to do these things:
 >
 > 1. Added an optional $return param to wp_mail().
 >   a. Because of the structure of the function, though, the
 trigger_error() calls are still necessary. The function only returns false
 | WP_Error if sending fails. There are cases where errors occur and
 sending is still successful. For example, if $to is valid, but there's an
 error in the CC header. If we remove the trigger_error() calls, those
 errors will continue to be ignored and undetectable.

 I can't form a strong opinion whether failing to send to any of the
 recipients should be considered as failure to send. Is there any facility
 in WP_Error to report "Worked, but ...."? OTOH failing to send an
 attachment should probably be reported as a failure.

 In other words, maybe if there was an error, the error object should be
 returned and let the caller decide about the severity of the error.

 > I don't think there's a way to translate the error messages thrown by
 PHPMailer, since they're in a variable rather than a string. Is that
 correct?

 My PHP inheritance knowledge isn't great but can't you extend phpmailer
 and override its setLanguage function or just setup its language array by
 using the translation function?

 Other remarks:
 1. I don't think the error codes should be prefixed with "phpmailer_". If
 some day phpmailer will be replaced it will make no sense.

 2. In wp_login.php, might as well display the error message from the
 WP_Error object if one was returned instead of the generic "'Possible
 reason: your host may have disabled the mail() function..."

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/23291#comment:20>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list