如果您遵循此示例,则没有理由它不应该工作:
<?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);
?>
注意:为了使上述示例工作,除了 Pear Mail 一个之外,还需要 Pear Mail Mime 包。你可以在这里获取包https://pear.php.net/package/Mail_Mime/download。