PHPMailer 无法实例化邮件函数


PHPMailer Could not instantiate mail function

我正在使用简单的代码:

$mailer = new PHPMailer();
$mailer->IsMail();
$mailer->IsHTML(true);
$mailer->CharSet = 'utf-8';
$mailer->From = 'from@domain.com';
$mailer->Sender = $this->title;
$mailer->FromName = SITE_TITLE;
$mailer->Subject = $this->theme;
$mailer->Body = $this->text;
$mailer->AddAddress($this->mail);
$result = $mailer->Send();
主题、正文、发件人

名称、发件人始终相同。它适用于某些电子邮件,但不适用于具有相同域名的其他电子邮件。例如,它适用于电子邮件:some@mydomain.com,但不适用于 someAnother@mydomain.comPHPMailer总是给我发送错误信息:无法实例化邮件功能。

使用cmd,我可以使用下一个命令在任何地址上发送电子邮件:

 echo "bla bla" | /usr/sbin/sendmail -f from@domain.com -v someAnother@mydomain.com -t -i

PHP INI:sendmail_path =/usr/sbin/sendmail -t -i

PHP 版本: 5.5PHPMailer Ver: 5.2.7

我会很高兴得到任何帮助!

sendmail 命令中的-f和发件人地址之间不应有空格,因此应-ffrom@domain.com而不是-f from@domain.com。当PHPMailer调用sendmail时,这是内置在它的命令行中的,所以我怀疑这是问题所在。

传递给它的参数称为信封发件人,应该是电子邮件地址(这是退回邮件的位置)。它不必与发件人地址相同,但通常是相同的。您正在设置$mailer->Sender = $this->title;我怀疑$this->title中的不是电子邮件地址。