在php邮件中构建带变量的html链接

Using the PHP mail function I need to send out an email that includes a link back to a record that has been modified, the link will need to contain the $id of the record that was modified on the database.

So far I have the email built, however am not sure on how I can include the link with variable.

mail('test@domain.com', 'Visitor Record Updated', "Hello,

The visitor record for " . $firstname . " " . $lastname . " Has been updated.

You can view the changes" . $url ."

Thank You");

That is how I plan to have the email sent, however how can i build the $url variable so that it sends the link as

http://app.site.com/visitor-view.php?id=$id
mail('test@domain.com', 'Visitor Record Ppdated', "Hello,

The visitor record for " . $firstname . " " . $lastname . " Has been updated.

You can view the changes: http://app.site.com/visitor-view.php?id=" . $id ."

Thank You");

You can send simple link. But it may not clickable in some email provides. So You have to send as html email:

Refer below link for more details

http://css-tricks.com/sending-nice-html-email-with-php/

If you want to add CSS, then you can add as inline style.

From above link i prepared for your question:

** prepare content of email**

$content ="<html><head><title>Welcome to Mysite</title></head>
<body>
<p>Hello,<br/><br/>
  The visitor record for " . $firstname . " " . $lastname . " Has been updated.<br/><br/>
  You can view the changes <a href='".$url."'>Here</a></p>

<p>Thank You</p>
</body></html>"; 


$to = 'test@domain.com';

$subject = 'Visitor Record Updated';

$headers = "From: noreply@domai.com
";
$headers .= "Reply-To: info@yourdomain.com
";
$headers .= "MIME-Version: 1.0
";
$headers .= "Content-Type: text/html; charset=ISO-8859-1
";

mail($to, $subject, $content, $headers);