OJS 3.0.1.0 sends mail after smtp is turned Off

Hello, I turned Off smtp in config.inc.php and put non existent data for smtp server but OJS 3.0.1.0 still sends mails. I unchecked sending mail in Admin interface to editor. How to stop OJS to send mails?

Thanks,

If you turn off smtp, OJS will use PHP’s native mail sending capability. You can block message sending at the system level, but that is outside the scope of this forum. You could also re-enable SMTP, but provide invalid SMTP information. The downside here is that you will be logging a lot of errors when the SMTP connections are attempted.

When I want to shutdown emailing for development purposes, I rewrite all of the email addresses to disposable accounts. Mailinator offers such a service. You could point them all to localhost with a global redirect. The script I use is only tested on 2.4.x and is a one-way operation (you can’t later reset the email to the original address).

#!/bin/bash
#MungeEmails.sh
# If OJS is installed in /var/www/html/ojs, and you want to use mailinator:
# ./MungeEmails.sh /var/www/html/ojs/config.inc.php mailinator.com
if [ "$#" != "2" ]
then
        echo "Usage: $0 config emailDomain"
        exit 1
fi

CONFIG=$1
MYSQLDATABASE=
MYSQLUSER=
MYSQLPW=
if [ -e "$CONFIG" ]
then
        MYSQLDATABASE=`grep '^name = ' $CONFIG | sed -e 's/name = //'`
        MYSQLPW=`grep '^password = ' $CONFIG | sed -e 's/password = //'`
        MYSQLUSER=`grep '^username = ' $CONFIG | sed -e 's/username = //'`
        echo "This is a one way ticket with no backup"
        echo -n "Type 'yes' if you really want to munge the emails for database '$MYSQLDATABASE': "
        read USERCONFIRM
        if [ "$USERCONFIRM" != "yes" ]
        then
                >&2 echo "Aborting"
                exit 1
        fi
        if [ "$MYSQLUSER" != ""  -a "$MYSQLPW" != "" -a "$MYSQLDATABASE" != "" ]
        then
                echo "select concat('update \`', table_schema, '\`.', table_name, ' set ', column_name, ' = concat(replace(', column_name, ', "'"'"@"'"'", "'"'"."'"'"), "'"'"@$2"'"'") where ', column_name, ' like "'"'"%_@_%"'"'"; select row_count() as updates, "'"'"', table_name, '.', column_name, '"'"'" as field;') from information_schema.columns where column_name like '%email' and data_type like '%char' and table_schema = '$MYSQLDATABASE';" | mysql -N -u $MYSQLUSER -p$MYSQLPW -D$MYSQLDATABASE | while read updatestmt
                do
                        echo "$updatestmt" | mysql -N -u $MYSQLUSER -p$MYSQLPW -D$MYSQLDATABASE
                done
                echo "select concat('update \`', n.table_schema, '\`.', n.table_name, ' set ', v.column_name, ' = concat(replace(', v.column_name, ', "'"'"@"'"'", "'"'"."'"'"), "'"'"@$2"'"'") where ', n.column_name, ' like "'"'"%email"'"'" and ', v.column_name, ' like "'"'"%_@_%"'"'"; select row_count() as updates, "'"'"', n.table_name, '.', v.column_name, '"'"'" as field;') from information_schema.columns n, information_schema.columns v where n.column_name = 'setting_name' and n.data_type like '%char' and v.column_name = 'setting_value' and v.data_type = 'text' and n.table_schema = v.table_schema and n.table_name = v.table_name and n.table_schema = '$MYSQLDATABASE'" | mysql -N -u $MYSQLUSER -p$MYSQLPW -D$MYSQLDATABASE | while read updatestmt
                do
                        echo "$updatestmt" | mysql -N -u $MYSQLUSER -p$MYSQLPW -D$MYSQLDATABASE
                done
        else
                >&2 echo "$CONFIG not parsed"
        fi
else
        >&2 echo "$CONFIG not found"
fi

Hi @vvucic,

How did you put non existent data for smtp server? I do not understand, can you please explain? Thanks!

Dung.

If you turn smtp = On in config.inc.php, but set an invalid smtp_server and/or smtp_port, OJS will try to connect to the invalid server, fail, and log an error rather than sending the mail.

To prevent long timeouts, you may want to target a port which will terminate the connection immediately.

Hi @ctgraham ,

What log file and its location does it log to, syslog, apache error.log, or OJS application log php_errors.log? Thank you!

Dung.

This would record errors in the PHP error log (which is often the same as the Apache error log).

Ok Thanks @ctgraham!

Hello @ctgraham,

when going to page https://server.com/index.php/arctic/editor/submissionReview/67638 and click envelop icon beside editor, to send an email to user, see attachment. I did not find a record recorded in mail_log table of the database after that. So question is what email does this mail_log table log? Thank you!

ScreenClip%20%5B3%5D

@ctgraham Sorry I looked at the wrong database. So sorry please ignore my previous question. they are logged in email_log table.

Details of test cases for those who are interested in OJS email notification troubleshoot:

trying to send from submission review (envelop icon beside editor field) https://1.1.2.2/index.php/arctic/editor/submissionReview/67638

1/ with Valid (smtp_server = smtp.gmail.com and smtp = On) in config_inc.php. Resulted in successful email delivery, log record found in db table email_log, and as expected no log record in var/log/syslog NOR application log ojs/php_errors.log NOR apache error.log

2/ with Invalid (smtp_server = oknotarealserver.company.com and smtp = On) in config_inc.php. Resulted in UNsuccessful email delivery, and as expected no log record found in db table email_log NOR var/log/syslog NOR application log ojs/php_errors.log NOR apache error.log

3/ with Valid (smtp_server = smtp.gmail.com and smtp = Off) in config_inc.php. Resulted in UNsuccessful email delivery, and as expected no log record found in db table email_log, but log record found in var/log/syslog(see below 3*), and no record found application log ojs/php_errors.log, and error found in apache error.log(3**)

(3*) Mar 1 11:41:16 ojs3-upgrade apache2: [01-Mar-2019 11:41:16 America/Denver] mail() on [/var/www/html/ojs-2.4.8-3/lib/pkp/classes/core/String.inc.php:297]: To: dl@university.ca – Headers: Content-Type: text/plain; charset=“utf-8” X-Mailer: Public Knowledge Project Suite v2 X-Originating-IP: 10.7.10.5 Date: Fri, 01 Mar 2019 11:41:16 -0700 From: “ojs admin” ojshelp@unversity.ca

note that for var/log/syslog to log you need to turn it on in your php.ini (mail.log = syslog)

(3**) sh: 1: /usr/sbin/sendmail: not found

and note that in (3**) sendmail is not installed on server (therefore OJS mail() function will not be able to fallback to local sendmail client):

to check for sendmail status do this:

root@ojs3-upgrade:~# sendmail status
The program ‘sendmail’ can be found in the following packages:

  • exim4-daemon-heavy
  • exim4-daemon-light
  • postfix
  • citadel-mta
  • courier-mta
  • dma
  • esmtp-run
  • masqmail
  • msmtp-mta
  • nullmailer
  • opensmtpd
  • qmail-run
  • sendmail-bin
  • ssmtp
    Try: apt install
    root@ojs3-upgrade:~#
1 Like