PHP generates and sends broken link emails

and sorry for my english.

I am creating a link with php. I am sending it by email. Several times the link (via email) is broken.

When I click (or copy to the browser), an empty space is inserted into a random position.

any idea?

generate mail, the code is as follows:

$url="www.example.com/dir/subdir/page.php?param1=$p1&param2=$p2&param3=$p3[...]&param20=$p20";
    [...]
    $body .= "<td><a href=\"$url\">";
    $body .= htmlentities($url,ENT_NOQUOTES,'ISO-8859-1');
    $body .= "</a></td>";
    [...]

$headers  = "From: $companyName < $companyMail > \r\n";
$headers .= "Reply-To: $companyMail \r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1 ";
$headers .= "Content-Type: text/html; charset=ISO-8859-1";
$headers .= "MIME-Version: 1.0 ";

mail($client, "Confirmaton", $body, $headers);

Example returned parameters on page.php

the code:

echo "<pre>Request:<br>";
print_r($_REQUEST);
echo "</pre><br>";
exit;


case OK:
Request:
Array
(
    [p1] => value1
    [p2] => value2
    [p3] => value3
    [p3] => value5
    [p4] => value6
    [p5] => value7
    (...)
    [p20] => value20

)

Error1 (link with space in value)
Request:
Array
(
    [p1] => value1
    [p2] => val ue2
    [p3] => value3
    [p3] => value5
    [p4] => value6
    [p5] => value7
    (...)
    [p20] => value20

)

Error2 (link with space in variable)
Request:
Array
(
    [p1] => value1
    [p2] => value2
    [p_3] => value3
    [p3] => value5
    [p4] => value6
    [p5] => value7
    (...)
    [p20] => value20

)
+4
source share
2 answers

Try to force php to avoid link wrapping:

$link = wordwrap($url, 255, "\r\n");

This can be caused by line breaks that each email client places in email bodies.

0
source

, URL. . SMTP-. , RFC 2821 5321 : , 1000 ( 990) ( , ). SMTP-.

my <td> <tr>.

$body .= "<td><a href=\"$url\">";
$body .= htmlentities($url,ENT_NOQUOTES,'ISO-8859-1');
$body .= "</a></td>\n";
0

Source: https://habr.com/ru/post/1502594/


All Articles