swartjie Posted December 5, 2015 Share Posted December 5, 2015 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 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted December 6, 2015 Share Posted December 6, 2015 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'); } 0 Quote Link to comment Share on other sites More sharing options...
swartjie Posted January 20, 2016 Author Share Posted January 20, 2016 I am sorry I did not reply before, For some reason I could not. But this was very useful thank you sentq 0 Quote Link to comment Share on other sites More sharing options...
sentq Posted January 20, 2016 Share Posted January 20, 2016 I am sorry I did not reply before, For some reason I could not. But this was very useful thank you sentq you're welcome! 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.