我知道这很简单,但我的大脑因试图解决另一个问题而受到了冲击!
我正在使用php的邮件功能向用户发送电子邮件。以下是我的代码。请参阅a href链接,如何将其显示为php中的实际链接?
$email=someone@example.com;
$content= "Dear Whoever,
NB: Please click <a href=\"document.pdf\" target=\"_blank\">here</a> to read and download the terms and conditions.";
mail( "$email", "Welcome", $content, "From: support@example.com");
答案 0 :(得分:1)
如上所述,您的代码有错误。它应该是:
email='someone@example.com';
$content= "Dear Whoever,
NB: Please click <a href=\"document.pdf\" target=\"_blank\">here</a> to read and download the terms and conditions.";
mail( $email, "Welcome", $content, "From: support@example.com");
您需要在标题中将mime类型设置为HTML,并将其用作mail()函数中的参数。
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "\r\n";
$headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n";
$headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
$headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";
// Mail it
mail($to, $subject, $message, $headers);
虽然我通常使用SwiftMailer,但它还有其他简洁的功能。