• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Whitelist of emails to still send to even with $config['enableMail'] on

Jake B.

Well-known member
#1
If there was a way I could do something like this:

PHP:
$config['enableMail'] = false;
$config['enableMail']['whitelist'] = [
    'user1@domain.com',
    'user2@domain.com',
];
and it'll still send email to the users specified that'd enable testing emails after an import without accidentally having things sent incorrectly
 

Chris D

XenForo developer
Staff member
#2
For mail testing, regardless of the scenario, I'd recommend one of two things.

1. File transport

This lets you trap all mails and have them written out to the file system. Just add the following to config.php:
PHP:
/** @var $c \XF\Container */
$c->extend('mailer', function(\XF\Mail\Mailer $mailer)
{
    $transport = \XF\Mail\Mailer::getTransportFromOption('file', [
        'path' => \XF::getRootDirectory() . '/internal_data'
    ]);
    $mailer->setDefaultTransport($transport);
    return $mailer;
});
2. MailTrap.io

My personal favourite. This is a special SMTP server you can use and will make all of the emails you send in their webmail like interface. You can actually set it all up in the config.php file too similar to the above.

File transport is probably the easiest. Can do a similar config.php approach in XF1 too:
PHP:
$transport = new Zend_Mail_Transport_File([
    'path' => XenForo_Helper_File::getInternalDataPath()
]);
XenForo_Mail::setupTransport($transport);