[wp-trac] [WordPress Trac] #33972: static use of PHPMailer class results in stale state between calls to wp_mail()

WordPress Trac noreply at wordpress.org
Wed Sep 23 09:57:10 UTC 2015


#33972: static use of PHPMailer class results in stale state between calls to
wp_mail()
--------------------------+-----------------------------
 Reporter:  codebuddy     |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  4.3
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 I've just been chasing down a problem since upgrading to WordPress 4.3
 with mails sent via wp_mail() being sent with:

 Content-Transfer-Encoding: quoted-printable

 Auto switching to quoted-printable was added in the PHPMailer class which
 was upgraded in 4.3. The issue is that the internal state in $phpmailer is
 not properly cleared between calls to wp_mail(). There is an attempt to do
 this via:

         // Empty out the values that may be set
         $phpmailer->ClearAllRecipients();
         $phpmailer->ClearAttachments();
         $phpmailer->ClearCustomHeaders();
         $phpmailer->ClearReplyTos();

 But non of these methods reset the value of $this->Encoding. So if I make
 two calls to wp_mail() and the first one gets switched to quoted-printable
 the second one will be sent as quoted-printable even if it doesn't need to
 be.

 Would it not be better to just create a new instance of PHPMailer for each
 invocation of wp_mail() and let the constructor take care of it?

--
Ticket URL: <https://core.trac.wordpress.org/ticket/33972>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list