0

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

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>");
}
4

1 回答 1

3

你用错了:

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

mail()函数没有$from参数。你也应该把它扔进去$headers

于 2012-06-16T19:29:34.217 回答