使用PEAR邮件发送测试邮件时出现错误消息

时间:2012-07-24 02:33:04

标签: php email pear mime

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

<?
        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);
?>

邮件未发送。检查我的错误日志:

  

[24-Jul-2012 02:14:50] PHP致命错误:调用未定义的方法   /home/**/php/Mail/mime.php上的Mail_mimePart :: encodeHeader()   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']
        );
    }

1 个答案:

答案 0 :(得分:1)

include_once("Mail/mime.php");

应该是你的包含。