链接电子邮件显示完整的URL而不仅仅是锚文本

时间:2010-09-15 18:18:52

标签: php html

如果符合某些条件,我将使用以下代码发送电子邮件。它运作得相当好。但是,$link1显示为完整的URL,而不仅仅是锚文本。我怎么能只显示锚文本?

提前致谢,

约翰

$querye = mysql_query("SELECT subcheck FROM submission WHERE subcheck = '1' AND submissionid = '$submissionid' ");

if (mysql_num_rows($querye) == 1)
{

$email_query = "SELECT email FROM login WHERE username = '$submittor'";
$result = mysql_query($email_query);
if (!$result) {
        trigger_error('Invalid query: ' . mysql_error()." in ".$email_query);
}

if($row = mysql_fetch_assoc($result)) {
        $mailaddress = $row['email'];


$link1 = "<a href='http://www.domain.com/path/comments/index.php?submission=".urlencode($submission)."&submissionid=".urlencode($submissionid)."&url=".urlencode($url)."&countcomments=".urlencode($countcomments)."&submittor=".urlencode($submittor)."&submissiondate=".urlencode($submissiondate)."&dispurl=".urlencode($dispurl)."'>Comment Link</a>";

    $message1 = "
Someone made the following comment on your submission $submission:

$comment


Please click the link below to see the comment in context.

$link1


";      


        $queryem = mail($mailaddress, "Someone has commented on your submission 
                        $submission.", $message1, "FROM: no-reply@domain.com");
}else{
        // no rows found.
}

}
else
{
//your subcheck is not 1 / nothing was found
}

2 个答案:

答案 0 :(得分:1)

您需要发送适当的标头,表明它是HTML电子邮件。

参见手册中的示例#4:http://php.net/manual/en/function.mail.php

答案 1 :(得分:1)

您需要以HTML格式发送电子邮件,使用PHPmailer或mail()函数标题将mime类型更改为html。