我刚刚升级到 ubuntu 12.04,安装了 pear、mail 和 mail_mime。我正在使用下面的示例代码。它曾经可以工作,但我不确定是否在 php.ini 中进行了一些更改。自从我上次设置以来已经有一段时间了。我用 gmail smtp 服务器测试过,一切正常。
<?
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>This is a html message</p></body></html>'; // HTML version of the email
$crlf = "\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);
?>
有什么我想念的吗?我应该更改 php.ini 中的 sendmail_path 吗?或者其他的东西?