Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
in Q2A Core by
edited by

Getting the below error after submitting the question.

Fatal error: Cannot declare class phpmailerException, because the name is already in use in qa/qa-include/vendor/PHPMailer/class.phpmailer.php on line 4044

Although it displays the above error, still the question is getting submitted and added to the system successfully. However this error message is misleading to the users.  Check my site here.

1 Answer

0 votes

I think you must be including the PHPMailer files more than once somehow. Do you have any custom plugins? And what version of Q2A are you running?

Could you try changing this line in qa-include/vendor/PHPMailer/PHPMailerAutoload.php:

require $filename;

to this:

require_once $filename;

QA Version - 1.8.0

I see only below 2 lines that are already in the format you suggested.

require_once QA_INCLUDE_DIR . 'vendor/PHPMailer/class.phpmailer.php';
require_once QA_INCLUDE_DIR . 'vendor/PHPMailer/class.smtp.php';

I haven't added any custom plugins recently before this error started to occur.
Which version of PHP are you using? Can you try updating to the latest version, 1.8.4, there was a fix in one of those versions related to PHPMailer.
It seems upgrading to PHP version 7.4.9 resolved the issue. I am also planning to upgrade to the latest version of QA 1.8.5.