I'm sending emails via mail()
that include an URL with a variable, that allows recipients to view filtered contents only.
$text_body= "anglebracket_a_href='https://example.com/list.php?var=$variable'">Link anglebracket/a>"
Variables are stored in a mysql database. Everything works fine so far, but the URL displays differently in every mail client.
Instead of the correct version:
<br>
https://www.example.com/list.php?var=76733d141
In Thunderbird it reads
<br>
tps://www.example.com/list.php?varv733d141*
(https truncated! and = sign and the first 2 digits turn into av)
In Webmail it reads
<br>
https://www.example.com/list.php?varv733d141
In my iPhone mail app it displays correctly and the link is clickable and works!
These are my headers:
$recipient = "test@example.com";
$subject="Your Login Data for $var1 at $var2 in $var3";
$text ="";
$text .=$text_body;
$sender = "Test <noreply@example.com>";
$headers = array();
$headers[] = "MIME-Version: 1.0";
$headers[] = "Content-Type: text/HTML; charset=ISO-8859-1";
$headers[] = "Content-Transfer-Encoding: quoted-printable";
$headers[] = "From: {$sender}";
$headers[] = "Reply-To: {$sender}";
$headers[] = "Subject: {$subject}";
$headers[] = "X-Mailer: PHP/".phpversion();
mail($recipient, $subject, $text,implode("\r\n",$headers));
Tried different encodings and delimiting and everything. Which basic or not so basic problem am I overlooking? Thanks for any help!
Since you say that you're sending quoted-printable, you should actually encode it properly. The =
character has special meaning in quoted-printable encoding. Use the quoted_printable_encode()
function to encode the body.
mail($recipient, $subject, quoted_printable_encode($text),implode("\r\n",$headers));
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.