-1

Below is PHP code related to sending mails, This code is functioning well except the link is not displayed. Its like a normal text. Also break tags are displayed as it in the code. I think the Error is in the message string. Can I know how to fix this issue.

 if(isset($_POST['submit'])){
    $from = "#"; // sender
    $to=$email;
    $subject="Email verification";
    $message='Hi, <br/> <br/> We need to make sure you are human. Please verify your email and get started using your Website account. <br/> <br/> <a href="'.$base_url.'activation/'.$activation.'">'.$base_url.'activation/'.$activation.'</a>';

     $message = wordwrap($message,50);
    mail($to,$subject,$message,"From: $from\n");
cmit
  • 261
  • 2
  • 7
  • 15
  • 1
    You have to send a header `Content-Type` with `text/html`. So that clients know that they have to read the email as HTML. `mail()`s 4th paramter gives you the possbility to send headers. – TiMESPLiNTER Oct 03 '14 at 14:29

1 Answers1

3

You're sending your email as plain text, not in HTML. As a result the HTML is just displayed and not rendered.

$from    = "#"; // sender
$to      = $email;
$subject = "Email verification";
$message = 'Hi, <br/> <br/> We need to make sure you are human. Please verify your email and get started using your Website account. <br/> <br/> <a href="'.$base_url.'activation/'.$activation.'">'.$base_url.'activation/'.$activation.'</a>';
$msg     = wordwrap($message,50);
$headers = "From: " . $from . "\r\n";
$headers .= "Reply-To: ". $from . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

mail($to,$subject,$message,$headers);
John Conde
  • 217,595
  • 99
  • 455
  • 496