Sikarjan Sikarjan - 1 year ago 60
PHP Question

PHP issue sending mail with link and get information

I am trying to send some text with a link with php mail() as plain text. The link looks like this
But in the mail I receive the link looks like this If I send an '=' alone it is no problem but if I have an equal and a number it is not working anymore.

Here is the code I use for sending the mail:

$header[] = 'MIME-Version: 1.0';
$header[] = 'Content-Type: text/plain; charset=UTF-8';
$header[] = 'Content-Transfer-Encoding: quoted-printable';
$header[] = $from;

mail($mail,$titel, $text, implode("\r\n",$header));

Can someone help me to fix this?


If I take a look at the Thunderbird mail source code everything is okay but it is displayed wrong.

MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
From: admin <>
Message-Id: <>
Date: Sat, 14 May 2016 23:38:35 +0200 (CEST)

I also tried to send the link as text/html and to wrap it into a proper tag but nothing worked. The link is always broken.


Answer Source

By looking through the source code of different mails I found this line in the header:

Content-Transfer-Encoding: 7bit

After changing my PHP header to this:

$header[] = 'MIME-Version: 1.0';
$header[] = 'Content-Type: text/plain; charset=UTF-8';
$header[] = 'Content-Transfer-Encoding: Content-Transfer-Encoding: 7bit';
$header[] = $from;

mail($mail,$titel, $text, implode("\r\n",$header));

I got it working. Links are displayed correctly now.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download