What encoding Content-Transfer-Encoding should be used when sending PHP-mail (), containing a long http-link?

I have a script that sends emails that look something like this:

$headers = "From: test@example.com\r\n"; $headers .= "Reply-To: test@example.com\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/plain; charset=utf-8\r\n"; $headers .= "Content-Transfer-Encoding: 8bit"; $orgsubject = "A subject with some swedish characters like å, ä and ö"; $newsubject='=?UTF-8?B?'.base64_encode($orgsubject).'?='; $body = 'A lot of text. Some more text. A long URL: http://example.com/subpage/?id=1234&hash=23jh4lk2j3h4lkjh674598xzxlk2j34h&anotherhash=h2k3j4h23kh42kj34h2lk3'; 

It has been fully tested, but some users, I think Outlook users, get a URL similar to this: http://example.com/subpage/?id=3D1234&hash=3D3D23jh4lk2j3h4lkjh674598xzxlk2j34h&anotherhash=3Dh2k3j4h23kh42kj34hl which matches the 3D, which The URL is useless in my case. I suppose this has something to do with Content-Transfer-Encoding, or perhaps with the Content type, do I need to encode the body message to base64 or something like that?

Update

I just found this post on the forum: https://stackoverflow.com/a/3/3/2/2/2/2/ So I deleted Content-Transfer-Encoding and it seems to work fine, but on the other hand, I could never reproduce the error in which the URL The address contained the text "3D", so I can’t be sure that it will work. Does anyone know if Content-Transfer-Encoding will remove my problem?

+8
content-type php
source share
1 answer

Do not mention this in your question, but =3D is an escape sequence quoted printable transfer encoding; It is used to securely transmit 8-bit data using 7-bit encoding.

There are still mail servers that do not like rows longer than 76 columns, and intermediate servers MAY cancel your message without updating message headers, which will lead to observable behavior.

Starting with 5.3.0, you can use quoted_printable_encode() to encode your message and adjust the Content-Transfer-Encoding header accordingly:

 Content-Transfer-Encoding: quoted-printable 

Setting up explicit transfer coding is a good practice that you should adopt, rather than a naive "somehow work" approach :)

+3
source

All Articles