在php邮件中使用变量构建html链接
使用PHP邮件功能,我需要发送一封电子邮件,其中包含一个指向已修改记录的链接,该链接需要包含数据库中已修改记录的$id 到目前为止,我已经建立了电子邮件,但我不知道如何才能包括变量的链接在php邮件中使用变量构建html链接,php,email,url,Php,Email,Url,使用PHP邮件功能,我需要发送一封电子邮件,其中包含一个指向已修改记录的链接,该链接需要包含数据库中已修改记录的$id 到目前为止,我已经建立了电子邮件,但我不知道如何才能包括变量的链接 mail('test@domain.com', 'Visitor Record Updated', "Hello,\r\n\r\nThe visitor record for " . $firstname . " " . $lastname . " Has been updated.\r\n\r\nYou ca
mail('test@domain.com', 'Visitor Record Updated', "Hello,\r\n\r\nThe visitor record for " . $firstname . " " . $lastname . " Has been updated.\r\n\r\nYou can view the changes" . $url ."\r\n\r\nThank You");
这就是我计划发送电子邮件的方式,但是我如何构建$url变量,以便它以如下方式发送链接
http://app.site.com/visitor-view.php?id=$id
你可以发送简单的链接。但在某些电子邮件中,它可能不可点击。 因此,您必须以html电子邮件的形式发送: 有关更多详细信息,请参阅下面的链接
http://css-tricks.com/sending-nice-html-email-with-php/
如果您想添加CSS,那么可以添加为内联样式
从上面的链接中,我准备回答您的问题:
**准备电子邮件内容**
$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\r\n";
$headers .= "Reply-To: info@yourdomain.com\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
mail($to, $subject, $content, $headers);
$content=“欢迎来到Mysite
你好,
访客记录为”$名字。" " . $姓。“已更新。
您可以查看更改
多谢各位
";
$to$test@domain.com';
$subject='Visitor Record Updated';
$headers=“From:noreply@domai.com\r\n“;
$headers.=“回复:info@yourdomain.com\r\n“;
$headers.=“MIME版本:1.0\r\n”;
$headers.=“内容类型:text/html;字符集=ISO-8859-1\r\n”;
邮件($to、$subject、$content、$headers);
您还可以使链接可点击:
$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\r\n";
$headers .= "Reply-To: info@yourdomain.com\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
mail($to, $subject, $content, $headers);