I wanted to run this by someone before possibly opening a bug…
After spending some time looking at why some mail-tags that allow replacement of from/to/and other headers in Contact Form 7 were not working (but not throwing an error), I started adding a bunch of debug statements in CF7. Everything looked fine, and where it called wp_mail(), there was no error.
I then moved on to adding more debug stuff in wp-includes/pluggable.php.
I followed things down to around line 260 where individual headers are parsed, and then down to line 303 where the reply-to is added. My debugging showed me that even though I was in that block within the switch statement, my “reply-to” was not being added. I was however able to see that I had the formatting wrong – there were multiple recipients, and I had “<firstname.lastname@example.org, email@example.com>” which got chunked into two addresses, “<firstname.lastname@example.org” and “email@example.com>”, neither of which passed PHPMailer’s validation.
My thought is that if there’s an error in adding any of these addresses, wp_mail() should pass it on up the chain. The whole routine is wrapped in “try/catch”, but nothing is done with the error.
Is this perhaps considered a bug in that end users of anything that calls “wp_mail()” (core, plugins) would spend an inordinate amount of time tracking down why mail is not sending… Thoughts?
I also elaborated on this in the CF7 forum (https://wordpress.org/support/topic/mail-tags-ignored-for-from-and-reply-to/?view=all), if that’s at all helpful, but to be clear, I’m NOT asking about plugin help, just wp_mail() itself and error handling…
- The topic ‘wp_mail() hiding recipient errors’ is closed to new replies.