My OJS installation can’t send emails. The error log shows “Could not instantiate mail function”.
I’m running OJS 3.3.0.11, but this problem also occurred in OJS 3.3.0.10.
There were no problems for months, then this problem started to creep up intermittently. At first, the error occurred up to around 50% of the time, but now all email sending (e.g. “notify author”) fails with the error.
I’m not using SMTP (due to issues with the host).
The strange thing is, if I write a simple debug script using phpmailer (same version, 6.2.0), sending to the same addresses, and run the script on the same host, the email is sent fine!
Does anyone know how to fix it or how to troubleshoot further? Since I’m not using SMTP, I can’t seem to get OJS to return more detailed logs.
Just for info, this is the simple email sending debug script I used (addresses have been changed):
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require './Exception.php';
require './PHPMailer.php';
$mailer = new \PHPMailer\PHPMailer\PHPMailer(TRUE);
try {
$mailer->IsHTML(true);
$mailer->Encoding = 'base64';
$mailer->XMailer = 'Public Knowledge Project Suite v3';
$mailer->SetFrom('system@journal-name.org', 'OJS backend');
$mailer->AddReplyTo('editor@journal-name.org', 'Editor');
$mailer->AddAddress('author@university.edu', 'Author');
$mailer->Subject = 'Test email';
$mailer->Body = 'This is a <b>test email</b>';
$mailer->AltBody = 'This is a test email';
$mailer->Send();
} catch (Exception $e) {
echo $e->errorMessage();
} catch (\Exception $e) {
echo $e->getMessage();
}
?>