Search This Blog

Wednesday, November 21, 2018

Solution: Random space in the email

If emails you send out are being inserted random space, then one solution is to check and modify your email Content-Transfer-Encoding header. Changing this header from "7BIT" to "QUOTED-PRINTABLE" helps us to solve this problem. ( But one encoding may not fit all and one issue disappear and another issue comes up, so you need to do enough testing while you change the encoding ).

MimeBodyPart mbp2 = new MimeBodyPart();
mbp2.setContent(htmlbody, "text/html; charset=utf-8");
//mbp2.setHeader("Content-Transfer-Encoding", "7bit");
mbp2.setHeader("Content-Transfer-Encoding", "QUOTED-PRINTABLE");