Bhawesh
Bhawesh

Reputation: 99

link is not showing in email body in php

I am trying to to use a link in my email body but failed to do that, Whenever i send an email, email is sent but it contain only the plain text but i also want to print a link so that that link will redirect me to another page.

here is my php code,

<?php
include("admin/config.php");

$email=$_POST['email'];


/// mail to customer

$to=$email;
$subject="Thanks for Contacting with us";

// Message
$message = '
<html>
<head>
  <title>Request to Change Password</title>
</head>
<body>
  <p>You have requested to change password <br> Please follow the below link to change your password.<br><br></p>
  <p><a href="http://www.example.com/update-password.php">Change Password</a><br><br></p>
  <p>Regards<br></p>
  <p>http://www.example.com<br></p>
  <p>9999999999<br></p>
</body>
</html>
';
$from = 'MIME-Version: 1.0' . "\r\n";
$from.= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$from.= 'From: <no-reply@[email protected]>' . "\r\n";

 $mail =mail($to,$subject,$message,$from);
if ($mail == true){

header('location:forgot_password.php');
}

?>

Please help me out, thanks in advance

Upvotes: 0

Views: 83

Answers (1)

Vivick
Vivick

Reputation: 4991

The link is not "showing" because you wrapped it in a <p> tag which is for text (paragraph) only. Wrap the link in a <a> tag and set the href attribute accordingly :

<a href="your link">
    A descriptive texte or your link again
</a>

Upvotes: 1

Related Questions