PHPMailer无法实例化邮件功能

时间:2014-11-19 13:46:15

标签: php email phpmailer

我使用简单的代码:

$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();

Subject,Body,FromName,Sender始终相同。它适用于某些电子邮件,但它不能与其他具有相同域名的电子邮件一起使用。例如,它适用于电子邮件:some@mydomain.com,但它不能与someAnother@mydomain.com一起使用 PHPMailer总是向我发送errorinfo:无法实例化邮件功能。

使用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 VER:5.5 PHPMailer Ver:5.2.7

我会在任何帮助下感到高兴!

1 个答案:

答案 0 :(得分:1)

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

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