OJS 3 is not sending mail with the office365 SMTP settings

I am having problems with sending email authenticated by office 365. I have edited the email settings in config.inc with the SMTP office 365 settings and even then the email is not sent.

The OJS keeps trying to send the email. But it does not. The only error that is generated is timeout.

teste%20E-mail%20_

the e-mail settings are configured as below:

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

; SMTP server settings
smtp_server = smtp.office365.com
smtp_port = 587

; Enable SMTP authentication
; Supported mechanisms: ssl, tls
smtp_auth = tls
smtp_username = xxxx@xxxx.com
smtp_password = xxx

Hi @Gabriel,

Which version of the OJS are you using? There are some changes (I believe in the 3.1.2), I have not yet tested, but with previous version I was not able to get it working:

Regards, PrimoĆŸ

Hi @primozs,

my version of the OJS is 3.1.2

Hi @Gabriel,

Maybe you find help here: SMTP 3 ojs linux

Regards, PrimoĆŸ

Hi @primozs,

I accessed the post and did what was indicated, but the email is still not being sent.

In the log the only error found is “PHP Fatal error: Maximum execution time of 30 seconds exceeded”

Hi,

Did anyone solve the problem?
I also encountered the same problem and it was killing me for more than 5 days. Anyway, the problem is solved for my case.

I have edited the Mail.inc.php file to see the ErrorLog file (@ /var/log/apache2/error.log) and found that “default_envelope_sender” (sender email as your smtp host email) was not set to $f[‘email’]); variable even it is assigned in the “config.inc.php” file.

/lib/pkp/classes/mail

try {
$success = $mailer->Send();
if (!$success) {
error_log($mailer->ErrorInfo.‘DAZ2_’);
error_log($mailer->Host);
error_log($mailer->Port);
error_log($mailer->SMTPSecure);
error_log($mailer->Username);
error_log($mailer->Password);
error_log($recipientInfo[‘email’]);
error_log($f[‘email’]); // default_envelope_sender
error_log($mailer->Subject);
error_log(’–Body: '.$mailBody);
return false;
}
} catch (phpmailerException $e) {
error_log($mailer->ErrorInfo.‘DAZ2_’);
return false;
}
return true;

$f[‘email’] = Config::getVar(‘email’, ‘default_envelope_sender’);
This line can not detect the “default_envelope_sender” from “config.inc.php” file. So,
$mailer->SetFrom($f[‘email’], $f[‘name’]);
this line can not set the FROM email address correctly. It takes the admin email address which was set to admin account.

So, I changed the admin email account e-mail address to my SMTP host email address and the system was working for smtp.office365.com setting.

Hope this may help to those who are facing the same problem still now.

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

; SMTP server settings
smtp_server = smtp.office365.com
smtp_port = 587

; Enable SMTP authentication
; Supported mechanisms: ssl, tls
smtp_auth = tls
smtp_username = xxxx@xxxx.com
smtp_password = xxx

Thank you all. :wink:

This will depend on your specific version of OJS, but in the current release (OJS 3.1.2) to always set the envelope sender on your outgoing mail, the required configuration settings in config.inc.php are all four of these:

  • allow_envelope_sender = On
  • default_envelope_sender = your_address@your_host.tld
  • force_default_envelope_sender = On
  • force_dmarc_compliant_from = On
1 Like

I believe that we need a “frequent issues” or a wiki where such issues and explanations would be published. I was recently struggling with the same problem with office365 and was unable to figure it out by myself that DMARC settings should be forced.

There is an FAQs section here:
https://forum.pkp.sfu.ca/c/faqs

This would make a good entry. Honestly, I think the primary reason I haven’t written it up yet is because I don’t like our current configuration variables and hope to simplify them.

1 Like