Getting Fatal error:在PHP中使用Pear Mail发送电子邮件时,调用了未定义的函数parseAd


Getting Fatal error: Call to undefined function parseAddressList() while sending email using Pear Mail in PHP

我对php完全陌生。我正在尝试使用PHP梨电子邮件系统发送一封经过身份验证的电子邮件。每当我使用gmailsmtp发送电子邮件时,我都会收到以下错误

致命错误:在第255行调用C:''wamp''bin''php''php5.4.16''pear''Mail.php中未定义的函数parseAddressList()

这是我的应用程序的代码

<!--
    Sending an email using gmail smtp server, with authentication, ssl version
    eMail With Authentication SSL Version
-->

<?php
// Pear Mail Library
require_once "Mail.php";
require_once "Mail/RFC822.php";
$from = 'me1@gmail.com';
$to = 'me2@hotmail.com';
$subject = 'Hi!';
$body = "Hi,'n'nHow are you?";
$headers = array(
    'From' => $from,
    'To' => $to,
    'Subject' => $subject
);
$smtp = Mail::factory('smtp', array(
        'host' => 'ssl://smtp.gmail.com',
        'port' => '465',
        'auth' => true,
        'username' => 'me1@gmail.com',
        'password' => 'password'
    ));
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
    echo('<p>' . $mail->getMessage() . '</p>');
} else {
    echo('<p>Message successfully sent!</p>');
}

?>

有人能建议我如何使用PHP Pear邮件包通过gmail发送经过验证的电子邮件吗?提前感谢。

我的问题解决了。谢谢你的指导。

实际上,我在Mail.php文件中犯了一个错误。Acroding to other stackoverflow post PHP:PEAR邮件帮助我在Mail.php 中粘贴了以下文本

$Mail_RFC822=新邮件_RFC822();$addresses=$Mail_RFC822->parseAddressList($receives,'localhost',false);

但是缺少了一些how-,所以上面的行变成了

$Mail_RFC822=新邮件_RFC822();$addresses=$Mail_RFC822>parseAddressList($receives,'localhost',false);

这就是bug的原因。

现在我已经纠正了这一点,可以发送电子邮件了。

非常感谢。