"City" is defined as a keyword in an email when it opens in iPhone

oI created an API for sending mail in PHP. Below is my code

$content = $content."<br/><b>Address : </b>".$fromUser["address"];
$content = $content."<br/><b>City : </b>".$fromUser["city"];

$to = 'abc@gmail.com';

include('PhpMailer/class.phpmailer.php');

$mail = new PHPMailer();
$mail->IsSMTP();
$mail->SMTPAuth = TRUE;
$mail->SMTPSecure = "ssl";
$mail->Host = "smtp.gmail.com";
$mail->Port = 465;
$mail->Username = "####";
$mail->Password = "####";
$mail->setFrom("support@abc.io","abc");
$mail->isHTML(true);
$mail->AddAddress($to);
$mail->Subject = 'Test';

$mail->MsgHTML($content);

if ($mail->Send()) {
   return 1;
} else {
   return 0;
}

I get an email, but the keyword "City" in the content shows a hyperlink. I want to remove this.

Email screenshot I get

[Note: if I write 'City1' instead of 'City', the link is deleted]

thanks

+4
source share
1 answer

Your $ fromUser ["address"] starts with <a>, but there is no end of the tag inside the variable.

One way is to add stript_tags () for output.

$content = $content."<br/><b>Address : </b>".strip_tags($fromUser["address"]);
$content = $content."<br/><b>City : </b>".strip_tags($fromUser["city"]);

It would be best if strip tags were already populated with $ fromUser varialbe data.

0
source

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


All Articles