我有一个运行ubuntu的流浪盒并安装了postfix,我可以在命令行上发送测试邮件。我也可以启动一个php会话并发送带有邮件功能的邮件。
但是,从Wordpress中的脚本中,mail()函数不起作用,如果我调试错误,则来自phpmailer类的错误&#34;无法实例化邮件功能&#34;。< / p>
所以看起来phpmailer类正在覆盖Wordpress中的php邮件功能。任何想法我如何解决这个问题。我感觉它与缺少phpmailer类所期望的邮件所需属性有关。
错误来自以下函数:
protected function mailSend($header, $body)
{
$toArr = array();
foreach ($this->to as $toaddr) {
$toArr[] = $this->addrFormat($toaddr);
}
write_log('to arr');
write_log($toArr);
$to = implode(', ', $toArr);
write_log('to');
write_log($to);
write_log('sender');
write_log($this->Sender);
if (empty($this->Sender)) {
$params = ' ';
} else {
$params = sprintf('-f%s', $this->Sender);
}
write_log('params');
write_log($params);
if ($this->Sender != '' and !ini_get('safe_mode')) {
write_log('old_from');
write_log($old_from);
$old_from = ini_get('sendmail_from');
ini_set('sendmail_from', $this->Sender);
}
$result = false;
write_log($this->SingleTo);
if ($this->SingleTo && count($toArr) > 1) {
foreach ($toArr as $toAddr) {
$result = $this->mailPassthru($toAddr, $this->Subject, $body, $header, $params);
$this->doCallback($result, array($toAddr), $this->cc, $this->bcc, $this->Subject, $body, $this->From);
}
} else {
$result = $this->mailPassthru($to, $this->Subject, $body, $header, $params);
$this->doCallback($result, $this->to, $this->cc, $this->bcc, $this->Subject, $body, $this->From);
}
if (isset($old_from)) {
ini_set('sendmail_from', $old_from);
}
if (!$result) {
throw new phpmailerException($this->lang('instantiate'), self::STOP_CRITICAL);
}
return true;
}
并且在日志发件人中,没有设置params和old_from
答案 0 :(得分:0)
如果您的wordpress中的邮件功能不起作用,那么您的SMTP邮件功能会尝试