0

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

Sikarjan
  • 55
  • 1
  • 7
  • try to add a header $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n"; instead of 'Content-Type: text/plain; charset=UTF-8'; – Pardeep Poria May 08 '16 at 09:18
  • posssible duplicate of http://stackoverflow.com/questions/15711700/php-mail-how-to-put-an-html-link-in-an-email and http://stackoverflow.com/questions/29733471/send-link-using-php-mail-function – Pardeep Poria May 08 '16 at 09:21
  • Sorry, I should have mentioned that I already tried that. It is not helping. Also it is not a duplicate of the two mentioned question because I do not want to send a href link, I want to send the plain link. – Sikarjan May 14 '16 at 21:36
  • Show your content you are sending in email – Pardeep Poria May 15 '16 at 11:50
  • I did a test mail with just that link as you can see above. Unfortunately it is not Thunderbird. On my mobile the links is also broken. I can trick Thunderbird in displaying the right link by adding ?en=R1545 but that does not work on my mobile... – Sikarjan May 17 '16 at 10:35
  • Did you change the headers to text/html ? – Pardeep Poria May 17 '16 at 10:49
  • Hi Poria, thanks for looking into this. Yes, I already have done that. – Sikarjan May 20 '16 at 14:44

2 Answers2

0

Try to add a header

$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";

instead of 'Content-Type: text/plain; charset=UTF-8';

Hope it helps !

Pardeep Poria
  • 1,049
  • 1
  • 7
  • 12
0

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.

Sikarjan
  • 55
  • 1
  • 7