PHP Email&超链接 [英] PHP Email & Hyperlinks

查看:180
本文介绍了PHP Email&超链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的电子邮件中加入超链接,但它只显示为纯文本。我可能只是错过了在$ BODY部分中使用我的引号而我只是没有看到它。

I'm trying to include a hyperlink in my email but it is just showing as plain text. I'm probably just miss-using my quotes in the $BODY section and I'm just not seeing it.

echo "Activation Code: " . $emailString . " <br>";
mysql_query("INSERT INTO accounts 
(name, pass, email, activated, code) VALUES('$user', '$pass', '$email', 'false', '$emailString') ") 
or die(mysql_error()); 

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

$to = "$email";
$subject = "Hi!";
$body = '<html><head></head><body> Thank you for registering! Please go to this address to activate your account: <a href="'. $_SERVER['SERVER_NAME'] .'/PHP%20project/activate.php?activationCode='.$emailString.'">' .$emailString . '</a> </body></html>';
$from = "From:---@gmail.com";
if (mail($to, $subject, $body, $from, $headers)) {
    echo("<p>Message successfully sent!</p>");
} else {
    echo("<p>Message delivery failed...</p>");
}


推荐答案

你用错了:

 mail($to, $subject, $body, $from, $headers)

邮件() 函数没有 $来自参数。你也应该把它扔进 $ headers

The mail() function does not have a $from parameter. You ought to throw it into $headers as well.

这篇关于PHP Email&amp;超链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆