1

Here is how I'm try to send html email with base64 image using nodemailer.

html: `<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==" />`,

but instead of original html I receive email with following:

<img src=3D"data:image/png;base64,=
iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBK=
E0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=3D=3D" />

where/what adds these "3D" and how to send right base64 image? Thank you

CodeBy
  • 714
  • 4
  • 10
  • 25

1 Answers1

0

Basically = is replaced with =3D in your case. This is happening because of the email encoding system called quoted-printable, which allows non-ASCII characters to be represented as ASCII characters for email transportation.

In quoted-printable, any non-standard email octets are represented as an = sign followed by two hex digits representing the octet's value. 3D is hex (quoted-printable) representation of ASCII =.

Set Content-Transfer-Encoding : quoted-printable in the headers.

See What's a 3D doing in this HTML? for more information.

Ravi Shankar Bharti
  • 8,922
  • 5
  • 28
  • 52
  • I have add `headers: { 'Content-Transfer-Encoding': 'quoted-printable', },` to message options, but this doesn't help, I don't see image (in web-interface of my email provider). – CodeBy Jun 23 '17 at 10:08
  • I see my image only when I forward message and mail provider change Content-Transfer-Encoding from quoted-printable to 8-bit – CodeBy Jun 23 '17 at 11:39
  • What happens if you change the content-transfer-encoding to 8 bit yourself?? – Ravi Shankar Bharti Jun 23 '17 at 12:03
  • 2
    It change to base64, encode all message to base64 and image still not visible – CodeBy Jun 23 '17 at 12:45