OJS 3.0.2 does not send mails (PHP Mail function)

ojs3

#1

Good afternoon,

We are going to enter soon in publishing mode and we have detected that OJS 3.0.2 does not sent notifications of any type by mail.

We do not use any server SMTP or external, we simply need that the basic function PHP Mail() works. I have checked that the config archive of OJS has this option disabled (default).

The server has sendmail installed and it is able to send mails from command line:

echo “This is a test mail.” | mail -s Testing name@mail.com

Thanks.


#2

Hi @Ayax,

I’d suggest checking your server’s mail delivery logs to see whether/why the messages are being rejected. This should be logged.

Regards,
Alec Smecher
Public Knowledge Project Team


#3

Hi @asmecher

/var/log/mail.log

Sep  7 10:09:01 ########## sm-mta[14894]: v87D91sk014894: from=<root@##########.com>, size=881, class=0, nrcpts=1, msgid=<201709071309.v87D913M014893@##########.com>, proto=ESMTP, daemon=MTA-v4, relay=##########.com [127.0.0.1]
Sep  7 10:09:01 ########## sendmail[14893]: v87D913M014893: to=root, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30623, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (v87D91sk014894 Message accepted for delivery)
Sep  7 10:09:01 ########## sm-mta[14895]: v87D91sk014894: to=<root@##########.com>, ctladdr=<root@##########.com> (0/0), delay=00:00:00, xdelay=00:00:00, mailer=local, pri=31102, dsn=2.0.0, stat=Sent
Sep  7 10:39:01 ########## sendmail[14949]: v87Dd1Em014949: from=root, size=623, class=0, nrcpts=1, msgid=<201709071339.v87Dd1Em014949@##########.com>, relay=root@localhost
Sep  7 10:39:02 ########## sm-mta[14950]: v87Dd1WG014950: from=<root@##########.com>, size=881, class=0, nrcpts=1, msgid=<201709071339.v87Dd1Em014949@##########.com>, proto=ESMTP, daemon=MTA-v4, relay=##########.com [127.0.0.1]
Sep  7 10:39:02 ########## sendmail[14949]: v87Dd1Em014949: to=root, ctladdr=root (0/0), delay=00:00:01, xdelay=00:00:01, mailer=relay, pri=30623, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (v87Dd1WG014950 Message accepted for delivery)
Sep  7 10:39:02 ########## sm-mta[14951]: v87Dd1WG014950: to=<root@##########.com>, ctladdr=<root@##########.com> (0/0), delay=00:00:01, xdelay=00:00:00, mailer=local, pri=31102, dsn=2.0.0, stat=Sent
Sep  7 11:09:01 ########## sendmail[15031]: v87E914p015031: from=root, size=623, class=0, nrcpts=1, msgid=<201709071409.v87E914p015031@##########.com>, relay=root@localhost
Sep  7 11:09:01 ########## sm-mta[15032]: v87E91BB015032: from=<root@##########.com>, size=881, class=0, nrcpts=1, msgid=<201709071409.v87E914p015031@##########.com>, proto=ESMTP, daemon=MTA-v4, relay=##########.com [127.0.0.1]
Sep  7 11:09:01 ########## sendmail[15031]: v87E914p015031: to=root, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30623, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (v87E91BB015032 Message accepted for delivery)
Sep  7 11:09:01 ########## sm-mta[15033]: v87E91BB015032: to=<root@##########.com>, ctladdr=<root@##########.com> (0/0), delay=00:00:00, xdelay=00:00:00, mailer=local, pri=31102, dsn=2.0.0, stat=Sent
Sep  7 11:39:01 ########## sendmail[15237]: v87Ed15x015237: from=root, size=623, class=0, nrcpts=1, msgid=<201709071439.v87Ed15x015237@##########.com>, relay=root@localhost
Sep  7 11:39:01 ########## sm-mta[15238]: v87Ed1fw015238: from=<root@##########.com>, size=881, class=0, nrcpts=1, msgid=<201709071439.v87Ed15x015237@##########.com>, proto=ESMTP, daemon=MTA-v4, relay=##########.com [127.0.0.1]
Sep  7 11:39:01 ########## sendmail[15237]: v87Ed15x015237: to=root, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30623, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (v87Ed1fw015238 Message accepted for delivery)
Sep  7 11:39:01 ########## sm-mta[15239]: v87Ed1fw015238: to=<root@##########.com>, ctladdr=<root@##########.com> (0/0), delay=00:00:00, xdelay=00:00:00, mailer=local, pri=31102, dsn=2.0.0, stat=Sent
Sep  7 12:09:01 ########## sendmail[15309]: v87F91mT015309: from=root, size=623, class=0, nrcpts=1, msgid=<201709071509.v87F91mT015309@##########.com>, relay=root@localhost
Sep  7 12:09:01 ########## sm-mta[15310]: v87F91lH015310: from=<root@##########.com>, size=881, class=0, nrcpts=1, msgid=<201709071509.v87F91mT015309@##########.com>, proto=ESMTP, daemon=MTA-v4, relay=##########.com [127.0.0.1]
Sep  7 12:09:01 ########## sendmail[15309]: v87F91mT015309: to=root, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30623, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (v87F91lH015310 Message accepted for delivery)
Sep  7 12:09:01 ########## sm-mta[15311]: v87F91lH015310: to=<root@##########.com>, ctladdr=<root@##########.com> (0/0), delay=00:00:00, xdelay=00:00:00, mailer=local, pri=31102, dsn=2.0.0, stat=Sent

"stat=Sent"
But no email received in the inbox or spam folder


#4

Hi @Ayax,

I would suggest capturing one of the messages that’s being sent, headers and all, and testing your local mail delivery outside of OJS. The best way to capture a message’s complete details is probably to add some logging to the PHPMailer class; see the mailPassthru function in lib/pkp/lib/vendor/phpmailer/phpmailer/class.phpmailer.php.

Regards,
Alec Smecher
Public Knowledge Project Team


#5

Thank you, but I do not know how to add the logging to function mailPassthru…

EDIT: OJS3 support Exim as replacement of Sendmail?


#6

Hi @Ayax,

When you have SMTP disabled, OJS will use PHP’s mail function for delivery via a local MTA. My understanding is that this function will use Exim or Sendmail equally, whichever is on the system.

Regards,
Alec Smecher
Public Knowledge Project Team


#7

I had a similar issue due to my new server configurations.

If you are in a new Linux distro with SELinux, you should check if apache has permission to send mails and network connection.

Summarizing, this issue was solved for me, under RHEL 7 (some distros refer to apache as apache) with:
$ sudo setsebool -P httpd_can_sendmail 1
$ sudo setsebool -P httpd_can_network_connect 1


#8

Thank you, but I have Ubuntu without SELinux…

EDIT: Exim does not work either


#9

We experience the same problem and we solved using same email as admin as journal contact email.
For example:
Admin Email: ojs@yourdomain.com
Journal Contact Email: ojs@yourdomain.com

Regards,


#10

Hi @asmecher,

I have got same problem with OJS 3.1.1.4. This version does not send mails. Authors, reviewers don`t receive any notifications or direct mails.
How to solve this problem?

Regards,
Lazar


#11

Hi @Lazar_Stosic,

See this suggestion above.

Regards,
Alec Smecher
Public Knowledge Project Team


#12

Hi @asmecher ,
I am not sure if I can understand all above. I looked in mailPassthru function in lib/pkp/lib/vendor/phpmailer/phpmailer/class.phpmailer.php and have>

private function mailPassthru($to, $subject, $body, $header, $params)
{
//Check overloading of mail function to avoid double-encoding
if (ini_get(‘mbstring.func_overload’) & 1) {
$subject = $this->secureHeader($subject);
} else {
$subject = $this->encodeHeader($this->secureHeader($subject));
}

    //Can't use additional_parameters in safe_mode, calling mail() with null params breaks
    //@link http://php.net/manual/en/function.mail.php
    if (ini_get('safe_mode') or !$this->UseSendmailOptions or is_null($params)) {
        $result = @mail($to, $subject, $body, $header);
    } else {
        $result = @mail($to, $subject, $body, $header, $params);
    }
    return $result;
} 

What concrete I can do?


#13

Hi @Lazar_Stosic,

Have you checked your mail delivery logs?

Regards,
Alec Smecher
Public Knowledge Project Team