我想在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.
答案 0 :(得分:1)
你必须创建一个HTML电子邮件,如果你想从头开始做很多工作,那么很多事情实际上都会出错。
不要手动执行,而是使用 PHPMailer (http://phpmailer.worxware.com/)及其MsgHTML()
方法将HTML内容添加到邮件正文中。
答案 1 :(得分:0)
$var = "http://domain.com/verify.php?token=$token";
$message = "Please click <a href=\"{$var}\">here</a> to veify.";
答案 2 :(得分: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.";