I am trying to send some text with a link with php mail() as plain text. The link looks like this https://example.com?en=1509 But in the mail I receive the link looks like this https://example.com?en09 . 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?
[Edit]
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 <admin@example.com>
Message-Id: <20160514213835.DD631480051D@example.com>
Date: Sat, 14 May 2016 23:38:35 +0200 (CEST)
https://example.com?en=1545
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.
Thanks
Try to add a header
$headers .= 'Content-type: text/html; charset=utf-8' . "\\r\\n";
instead of 'Content-Type: text/plain; charset=UTF-8';
'Content-Type: text/plain; charset=UTF-8';
Hope it helps !
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.