Jump to content

Using PHPMail Library Causes Clash in Cron


swartjie

Recommended Posts

Hi,

 

I have a module that uses the PHPmail library to send emails after the cron runs for WHMCS.

When I set it to run before the cron, the error does not apear, but If I set it to run after the cron (which i need) I get the below error...

 

I assume it is because WHMCS uses the same PHPmailLibrary.

 

How can I stop this clash?

I cannot remove the link because the function which requires the phpmailer is also used outside of the HOOK, and outside I need to declare it.

 

Fatal error: Cannot redeclare class phpmailerException in /home/username/public_html/whmcs/modules/addons/addon_name/PHPMailer/class.phpmailer.php on line 3883

Link to comment
Share on other sites

use the "class_exists" function to check if the class was already loaded or not before loading it, for example if this is how you include/require the class file:

require('PHPMailer/class.phpmailer.php');

 

change it to:

if (!class_exists("PHPMailer")){
   require('PHPMailer/class.phpmailer.php');
}

Link to comment
Share on other sites

  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated