Can't send mail with OJS 3.1.1

php_error.php:

[17-Apr-2018 12:05:30 Europe/Madrid] PHP Warning:  Declaration of 
UserEmailForm::fetch($args, $request) should be compatible with 
Form::fetch($request, $template = NULL, $display = false) in 
 lib/pkp/controllers/grid/settings/user/form/UserEmailForm.inc.php on line 0

[17-Apr-2018 12:05:41 Europe/Madrid] PHP Warning:  Declaration of 
UserForm::display($args, $request) should be compatible with 
Form::display($request = NULL, $template = NULL) in 
lib/pkp/controllers/grid/settings/user/form/UserForm.inc.php on line 18

[17-Apr-2018 12:05:41 Europe/Madrid] PHP Warning:  Declaration of 
UserEmailForm::execute($args, $request) should be compatible 
with Form::execute() in
 lib/pkp/controllers/grid/settings/user/form/UserEmailForm.inc.php on line 0

[17-Apr-2018 12:05:41 Europe/Madrid] Could not instantiate mail function.

Help please

Hi @david_web

How is set your mail settings on your config.inc.php file?

Regards,
Israel Cefrin
Public Knowledge Project Team

;;;;;;;;;;;;;;;;;;
; Email Settings ;
;;;;;;;;;;;;;;;;;;

[email]

; Use SMTP for sending mail instead of mail()
; smtp = On

; SMTP server settings
; smtp_server = mail.example.com
; smtp_port = 25

; Enable SMTP authentication
; Supported mechanisms: ssl, tls
; smtp_auth = ssl
; smtp_username = username
; smtp_password = password

; Allow envelope sender to be specified
; (may not be possible with some server configurations)
; allow_envelope_sender = On

; Default envelope sender to use if none is specified elsewhere
; default_envelope_sender = my_address@my_host.com

; Force the default envelope sender (if present)
; This is useful if setting up a site-wide noreply address
; The reply-to field will be set with the reply-to or from address.
; force_default_envelope_sender = Off

; Amount of time required between attempts to send non-editorial emails
; in seconds. This can be used to help prevent email relaying via OJS.
; time_between_emails = 3600
time_between_emails = 60

; Maximum number of recipients that can be included in a single email
; (either as To:, Cc:, or Bcc: addresses) for a non-priveleged user
max_recipients = 10

; If enabled, email addresses must be validated before login is possible.
require_validation = Off

; Maximum number of days before an unvalidated account expires and is deleted
validation_timeout = 14

Hi @david_web

According to your settings you are using PHP mail function from your server. Could you confirm with your IT staff that it is working (PHP mail function)?

Regards,
Israel Cefrin
Public Knowledge Project Team

@david_web and @israel.cefrin, I was having a similar error of “Could not instantiate mail function”. This is running CentOS 7 with SELinux enabled. My fix was to:

  1. Set postfix’s relayhost to be our organizations SMTP host. This was done inside of /etc/postfix/main.cf:
[user@localhost dir]# grep relayhost /etc/postfix/main.cf  | grep -v ^#
relayhost = smtp.org.example.com
  1. Enable HTTPD to send mail with SELinux enabled
[user@localhost dir]# setsebool -P httpd_can_sendmail 
[user@localhost dir]# sestatus -b | grep -i sendmail
gitosis_can_sendmail                        off
httpd_can_sendmail                          on
logging_syslogd_can_sendmail                off

Hope this helps at least someone!

-Dave

2 Likes