我正在使用梨形郵件包通過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>");
}
?>
任何幫助是非常讚賞,
感謝。
您是將您的電子郵件作爲HTML電子郵件發送還是以純文本形式發送? – andrewsi
我假設它設置爲純文本。這是SMTP,所以我猜想它不支持HTML標籤。 – slickboy
你可以通過SMTP發送HTML郵件 - 你只需要在你的PHP中設置正確的設置。你想添加創建你的電子郵件的代碼嗎? – andrewsi