330

I'm trying to duplicate a mailer I got into my gmail by taking a look at its code. I see a lot of this in multiple source viewers:

 <td style=3D"border-bottom: 1px dotted rgb(153,157, 147); border-top: 1px solid rgb(28, 140, 78);" width=3D"90">=A0</td>
 <td style=3D"border-bottom: 1px dotted rgb(153,157, 147); border-top: 1px solid rgb(28, 140, 78);" align=3D"right" width=3D"110">

Is 3D some sort of mail rendering thing I don't know about?

Nic
  • 13,287
  • 7
  • 40
  • 42
  • 6
    PHP has a method for converting a quoted-printable string to an 8 bit string http://www.php.net/manual/en/function.quoted-printable-decode.php – John Magnolia Nov 24 '15 at 12:48

2 Answers2

465

It's an email encoding system called "quoted-printable", which allows non-ASCII characters to be represented as ASCII 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. Of course, to represent a plain = in email, it needs to be represented using quoted-printable encoding too: 3D are the hex digits corresponding to ='s ASCII value (61).

C. K. Young
  • 219,335
  • 46
  • 382
  • 435
  • 25
    Yup. You should see `Content-Transfer-Encoding: quoted-printable` in the headers if QP is used. – Piskvor left the building Oct 25 '10 at 15:30
  • 3
    Interesting! Do I need to incorporate that into my email template, or will it be ok without it? – Nic Oct 25 '10 at 15:34
  • 22
    @melee: Don't write in QP by hand (i.e., your template should use `=`, not `=3D`). :-) If your email software needs to use QP, it'll convert automatically. – C. K. Young Oct 25 '10 at 15:48
  • 82
    Saving you the inevitable search for a decoder: http://www.motobit.com/util/quoted-printable-decoder.asp – snappieT Nov 20 '14 at 10:47
  • In my case it was the use of one character in the email message that caused it to change `Content-Transfer-Encoding`. Replacing — with - solved it. – Nick Aug 03 '15 at 04:32
  • 1
    @Stephen, In the past there are no hex viewers, only text viewers. – Pacerier Sep 05 '16 at 13:43
  • 5
    To decode, one can use [the Python standard library's `quopri.decodestring(s)`](https://docs.python.org/library/quopri.html) – ShreevatsaR Apr 02 '19 at 21:58
  • 1
    This is why if you send an email in a non-Latin language such as Japanese, it will be encoded that way too! For example sending `こんにちは` results in `= =E3=81=93=E3=82=93=E3=81=AB=E3=81=A1=E3=81=AF` at the destination, which is quoted-printable encoding on top of UTF-8 encoding. – Michael Butler Oct 27 '20 at 00:44
  • If you are using PHP you can use quoted_printable_decode($htmlmsg) to remove the =xx and replace it with the right stuff. – bartonlp Apr 01 '22 at 17:22
  • This one works well too: https://www.webatic.com/quoted-printable-convertor – Mike Causer Sep 01 '23 at 08:23
-5

Folks from Google using Laravel, you can stop the Mail facade from adding all this weird 3D stuff by setting your encoder to raw:

$message->setEncoder(new Swift_Mime_ContentEncoder_RawContentEncoder);
bastinald
  • 145
  • 1
  • 8