-1

可能重复:
Php 邮件:如何发送 html?

我想在 PHP 中使用 Mail() 函数,但在消息中包含链接和变量时遇到了一些困难。

$to = "someone@example.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$from = "someonelse@example.com";
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
echo "Mail Sent.";

如何发送以下消息?

Please click <a href="http://domain.com/verify.php?token=$token">here</a> to veify.
4

3 回答 3

1

如果您想从头开始,您将不得不创建一个 HTML 电子邮件,这几乎是一项艰巨的工作,而且很多事情实际上都可能出错。

与其手动操作,不如使用PHPMailer ( http://phpmailer.worxware.com/ ) 及其MsgHTML()将 HTML 内容添加到消息正文的方法。

于 2012-05-02T23:50:15.973 回答
0
$var = "http://domain.com/verify.php?token=$token";
$message = "Please click <a href=\"{$var}\">here</a> to veify.";
于 2012-05-02T23:48:12.137 回答
0

尝试这个

$to = "someone@example.com";
$subject = "Test mail";
$message = "Hello! This is a simple email message.";
$message .="Please click <a href=\"http://domain.com/verify.php?token=\"{$token}\">here</a> to veify.";
$from = "someonelse@example.com";
$headers = "From:" . $from;
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\n";
mail($to,$subject,$message,$headers);
echo "Mail Sent.";
于 2012-05-02T23:48:52.743 回答