我正在使用 Pear Mail 包通过 G-Mail(使用 SMTP)为我正在开发的网站发送电子邮件。当有人在网站上注册时,用户必须首先单击他们收到的确认电子邮件中的链接,然后才能创建帐户。我遇到的问题是,我在电子邮件中嵌入的 URL 在我输入时按字面意思显示(显示 HTML 标记),即
<a href = '...'>...</a>
而不是作为可点击的 URL。关于如何使网址可点击的任何建议?我的代码或多或少与以下问题相同:Send email using the GMail SMTP server from a PHP page
<?php
require_once "/Mail/Mail-1.2.0/Mail.php";
require_once "/Mail/Mail-1.2.0/Mail_Mime-1.8.5/Mail/mime.php";
$from = "XYZ <XYZ.gmail.com>";
$email = $_GET['e'];
$to = $email;
$subject = "XYZ - Registration";
$body = "<html><body>Hi " . $_GET['f'] . ",\n\nThank You For Registering With XYZ\n\nPlease Click The Following Link To Confirm Your Account: <a href = 'www.test.com'>www.test.com</a></body></html>";
$crlf = "\n";
$mime = new Mail_mime($crlf);
$mime->setHTMLBody($body);
$body = $mime->get();
$host = "ssl://smtp.gmail.com";
$port = "465";
$username = "XYZ";
$password = "XYZPassword";
$headers = array ('From' => $from, 'To' => $to, 'Subject' => $subject);
$smtp = Mail::factory('smtp', array('host' => $host, 'port' => $port, 'auth' => true, 'username' => $username, 'password' => $password) );
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail))
{
echo("<p>" . $mail->getMessage() . "</p>");
}
else
{
echo("<p>Message successfully sent!</p>");
}
?>
任何帮助深表感谢,
谢谢。