Error with the Fabrik email plugin

fabrikWhen updating Fabrik, I've occasionally come across this issue.  The error occurs when a visitor fills in a form with the email plugin enabled.  This article describes the fix.  Remember to backup Joomla first.


Scenario

When completing a form, the 'Could not instantiate mail function' error occurs.  However when you check Joomla configuration, you can successfully send a test email.  Note that for this article I was using Joomla 3.6.5 and Fabrik 3.5.1.

 

Edit the email.php file

Open the /plugins/fabrik_form/email/email.php file for editing.

Replace the following code:

$res = FabrikWorker::sendMail(
  $emailFrom,
  $emailFromName,
  $email,
$thisSubject,
  $thisMessage,
  $htmlEmail,
  $cc,
  $bcc,
  $thisAttachments,
  $returnPath,
  $returnPathName,
  $customHeaders
);

 With this code:

$mail = JFactory::getMailer();
$res = $mail->sendMail(
  $emailFrom,
  $emailFromName,
  $email,
  $thisSubject,
  $thisMessage,
  $htmlEmail,
  $cc,
  $bcc,
  $thisAttachments,
  $returnPath,
  $returnPathName
);

 

Thanks for visiting.