phpList - Adding SPF/DKIM details

brandingSometimes in phpList, when sending by php mail() your emails may be classified as Spam! The dreaded Spam!

The solution to avoiding this is to use your own Email settings in place of the php mail() and if necessary, add SPF and DK records.

This tutorial has been updated to refer to version 3.2.7 of phpList.

First, open the lists/config/config_extended.php file, find the smtp section, around line 554-590

# To use a SMTP server please give your server hostname here, leave it blank to use the standard
# PHP mail() command. define("PHPMAILERHOST",'');
# in the above you can specify multiple SMTP servers like this: # 'server1:port1;server2:port2;server3:port3'  #define('PHPMAILERHOST','smtp1.mydomain.com:25;smtp2.mydomain.com:2500;smtp3.phplist.com:5123');
# if you want to use smtp authentication when sending the email uncomment the following # two lines and set the username and password to be the correct ones #$phpmailer_smtpuser = 'smtpuser'; #$phpmailer_smtppassword = 'smtppassword';
## you can set this to send out via a different SMTP port # define('PHPMAILERPORT',25);

Now Copy and Paste into the end of config/config.php file.*

Change the settings as follows, substituting your email settings as required.

define("PHPMAILERHOST",'mail.domain.com');

If necessary, you can now specify a port as well as the domain.

define("PHPMAILERHOST",'mail.domain.com:25');

Remove the two hash's from the following two lines and replace the two values with your own email login and password.

$phpmailer_smtpuser = 'email {AT} domain.com';
$phpmailer_smtppassword = 'your_password';

Check that this works by sending out a test message to yourself, remember that the email to which you are sending must exist as a subscriber, but now, if it doesn't, you'll be offered a link to add the email as a subscriber.

Hopefully, this works. if it doesn't you'll need to work out what detail you've got wrong when entering your email settings.

So, assuming you have successfully changed from PHP mail() to your own SMTP, you can now log in to your web server's cPanel and with some luck, you'll find an option to enable SPF**, might be a simple tick/click to enable SPF in your email sub-section, otherwise, you'll need to visit your preferred search engine and look for "SPF Wizard". Follow the instructions on this and add the SPF settings to your DNS (cPanel Domain settings) as a Custom TXT.

Now, again if your server cPanel offers to enable DK(IM), enable it, it's a doddle that way.

If not, run the SparkPost DKIM Wizard, start with your domain and key1, this takes you through the details you'll need, most of the time default settings are ok.

Again, follow the instructions on how to add DKIM to your domain, and set up the two Custom TXT fields in your DNS area (_domainkeys and key1_domainkeys) set the refresh time to 900 (or the minimum your host allows) save it all and after the minimum time, you should find your emails now have SPF and DKIM keys set.

It all helps cut down on your Campaigns being classified as spam.

You should also be able to check that your SPF records are correct, or combine the two at SparkPost's SPF/DKIM email validation and look for Email Tools under Additional Resources heading.

* phpList 3.3.x offers two config.php files, but only uses the actual config.php file, config_extended.php is there for reference and contains pretty much every configurable option available. To use this, rename it to replace the smaller config.php file.

** Note that SPF is becoming depreciated so you may not need to bother with this in the future.

 Last update: 2nd November 2020