0

我已经安装了最新版本的 PEAR Mail 和 Mail_Mime,我正在尝试使用此页面中的以下测试电子邮件发送测试消息,即

<?
        include('/home/****/php/Mail.php');
        include('/home/****/php/Mail/mime.php');

        // Constructing the email
        $sender = "**** <info@****.com>";                              // Your name and email address
        $recipient = "**** <****@gmail.com>";                           // 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);
?>

并且消息没有被发送。检查我的错误日志:

[2012 年 7 月 24 日 02:14:50] PHP 致命错误:调用 /home/ 中未定义的方法 Mail_mimePart::encodeHeader() * */php/Mail/mime.php 在第 1330 行

我想知道是否有人知道此错误消息与什么有关以及可以做些什么?mime.php 中的第 1330 行是此函数的第 4 行:

function encodeHeader($name, $value, $charset, $encoding)
    {
        $mime_part = new Mail_mimePart;
        return $mime_part->encodeHeader(
            $name, $value, $charset, $encoding, $this->_build_params['eol']
        );
    }
4

1 回答 1

1
include_once("Mail/mime.php");

应该是你的包括。

于 2012-07-24T23:49:40.447 回答