PHP Email & Hyperlinks

那年仲夏 提交于 2019-12-13 02:44:48

问题


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

回答1:


You're using it wrong:

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

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



来源:https://stackoverflow.com/questions/11066364/php-email-hyperlinks

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!