我正在使用PEAR邮件系统发送经过身份验证的邮件.我需要发送具有alink的HTML邮件.在我开始使用PEAR邮件之前它工作正常.现在我无法发送HTML邮件.
邮件正文如下:
$body = <<<EOD
Hiya $username
You might be interested in the current 'haves' and 'wants' on example.com
Latest Haves
<a href="http://www.exmaple.com/product/have/64/Titan+Fast+Track+SunGlass">Titan Fast Track SunGlass</a>
EOD;
Run Code Online (Sandbox Code Playgroud)
一个标签出现在邮件中.任何想法如何解决这个问题?请帮忙..
kar*_*m79 29
如果您遵循此示例,则没有理由不应该这样做:
<?php
include('Mail.php');
include('Mail/mime.php');
// Constructing the email
$sender = "Leigh <leigh@no_spam.net>";// Your name and email address
$recipient = "Leigh <leigh@no_spam.net>"; // The Recipients name and email address
$subject = "Test Email";// Subject for the email
$text = 'This is a text message.';// Text version of the email
$html = '<html><body><p>HTML message</p></body></html>';// HTML version of the email
$crlf = "\r\n";
$headers = array('From' => $sender, 'Return-Path' => $sender, 'Subject' => $subject);
// Creating the Mime message
$mime = new Mail_mime($crlf);
// Setting the body of the email
$mime->setTXTBody($text);
$mime->setHTMLBody($html);
$body = $mime->get();
$headers = $mime->headers($headers);
// Sending the email
$mail =& Mail::factory('mail');
$mail->send($recipient, $headers, $body);
?>
Run Code Online (Sandbox Code Playgroud)
注意:为了使上面的例子工作,除了Pear Mail之外,还需要Pear Mail Mime Package.你可以在这里获得包https://pear.php.net/package/Mail_Mime/download.
sto*_*ory 16
你的标题是什么样的?这是我的:
$headers = array(
'To' => $recipients,
'From' => $adminEmail,
'Subject' => $subject,
'MIME-Version' => 1,
'Content-type' => 'text/html;charset=iso-8859-1'
);
Run Code Online (Sandbox Code Playgroud)