在php生成的电子邮件中包含一个链接

时间:2013-02-27 15:17:30

标签: php email

我正在尝试在php生成的电子邮件中包含一个链接。我看过这里可以找到的例子,但我仍然无法让我的工作需要一些帮助。这就是我所拥有的:

    //send email when pricing specs are done
$to = $email;
$subject = "Final Check In";
$headers = "From: Warehouse@bookcellaronline.com" . "\r\n" .
"CC: micahpartnerships@gmail.com,lreyes@bookcellaronline.com,jimd@bookcellaronline.com";
$body = "Greetings " .$name."!\nWe have completed checking in your latest shipment of books.\nCheck-In date was: " .$finaldate."\n
We checked in " .$count." books.\nA total of " .$notListed." books are not listed yet and have been set aside to be researched.\nComments: ".$comments. "\n
You will now be able to review your shipment details here : '<a href = http:www.bookcellaronline.com/bcos/advances/buyertotal.php>Check In Details</a>'.  Use the Check-In date from above.\n
This is an automated email - do not reply to this email. If you have any questions or concerns, please contact your Manager or Abbie.\n";
$body = wordwrap($body,70);
mail($to, $subject, $body, $headers);

我显然错过了一些东西,但我不确定它是什么。 感谢

2 个答案:

答案 0 :(得分:5)

首先设置标题,内容为HTML 例如:

$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

然后添加像这样的链接

<a href = "http://www.bookcellaronline.com/bcos/advances/buyertotal.php">Check In Details</a>

答案 1 :(得分:0)

首先:不要使用mail()函数。使用像PHPMailer()这样的特定类。 真。不要这样做。

在这里缺少//:

<a href = http://www.bookcellaronline.com