PHP Email & Hyperlinks

2019-09-11 21:18发布

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条回答
做自己的国王
2楼-- · 2019-09-11 21:52

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.

查看更多
登录 后发表回答