I’ve got a vagrant box running ubuntu and postfix is installed and I can send a test mail from it on the command line. I can also start a php session and send a mail with the mail function from it.
However, from a script in WordPress the mail() function doesn’t work and if I debug the error it is an error coming from the phpmailer class “Could not instantiate mail function”.
So it looks like phpmailer class is overriding the php mail function in WordPress. Any ideas how I can resolve this problem. I’ve got a feeling it is to do with missing required attributes of the mail that phpmailer class is expecting.
error is coming from the following function:
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;
}
and in the logs sender, params and old_from are not set
If mail function is not working in your wordpress then your SMTP mail function and try