The config.php switch to disable emails is not working in my add-on

AndyB

Well-known member
Hello,

In my add-on I have the following which sends emails:

PHP:
// prepare mail variable
$mail = XenForo_Mail::create('weeklydigest_contact', $params);

// send mail
$mail->queue($user['email'], $user['username']);

In testing I see the following code entered into the config.php is not working to stop emails from being sent.

PHP:
$config['enableMail'] = 'false';

Should I add some code to my add-on to prevent this issue, or is the code in XenForo not working correctly?

Thank you.
 
The queue method of the mail class should already prevent emails from being sent if the config has mails disabled, e.g.

PHP:
if (!XenForo_Application::get('config')->enableMail)
{
   return true;
}
 
The queue method of the mail class should already prevent emails from being sent if the config has mails disabled, e.g.

Yes I saw that in the code, and I would assume that bit of code would prevent emails from going out, but it does not.
 
I missed it when I first looked.

PHP:
'false'
and
PHP:
false
is not the same thing.

The string 'false' will essentially evaluate to boolean value true.

Change your config.php to:
PHP:
$config['enableMail'] = false;
 
Back
Top Bottom