3

I'm having a strange issue with wp_mail() -- for some admin users, the sent message includes a

Content-Transfer-Encoding: quoted-printable

header, which breaks the HTML of the email message.

I'm using:

add_filter('wp_mail_content_type', create_function('', 'return "text/html";'));
add_filter('wp_mail_charset', create_function('', 'return "UTF-8";'));

To define the content type and charset.

This header doesn't get added for other users and the same email script sends normally.

Has anyone else encountered this? What's going on? Thanks!

HWD
  • 1,547
  • 7
  • 36
  • 72
  • PHPMailer automatically switches to quoted-printable encoding if lines within the message are too long (> 998 chars). This is independent of charset and content type. There shouldn't be anything particularly wrong with that - QP-encoding is entirely normal, so can you be more precise about what you mean by "breaking"? – Synchro Mar 25 '16 at 20:08
  • @Synchro When the email is quoted-printable, the HTML breaks because the characters get encoded printed like "=0A=09=0A=09" instead of their html elements. – HWD Mar 28 '16 at 05:17
  • Yes, that's what QP-encoding is, and all email clients know how to decode it. It has nothing to do with HTML, and it does not break HTML. FYI, `=09` is a tab, `=0A` is an LF character. – Synchro Mar 28 '16 at 05:29
  • But the entire email isn't getting encoded, so it returns some HTML and some still encoded characters, breaking the HTML. For example, the email will start with: `=0A=09=0A=09 – HWD Mar 28 '16 at 06:09
  • 1
    That is all normal, but there is a bug that only appears in outlook you may be running into. Make sure your lines are less than 998 chars long. – Synchro Mar 28 '16 at 06:13
  • Is there anything I can do programmatically ensure that the length isn't too long? For example, if someone uses a long URL to link an image with a long SRC, that line of code can quickly add up. – HWD Mar 28 '16 at 19:57
  • Not a lot. QP encoding exists specifically to deal with problems like that, so if you have a buggy client you're a bit stuck. – Synchro Mar 28 '16 at 20:04

0 Answers0