DKIM b= signature field is empty

I’ve configured in PHPMailer.php the DKIM variables ($DKIM_selector, $DKIM_identity, and so on …)

I get a dkim email as follows

DKIM-Signature: v=1;; s=dkimsel;
a=rsa-sha256; q=dns/txt; l=30; t=1573568421; c=relaxed/simple;

and the signature field is empty.

My DKIM configuration is OK. I can send without problems with other software dkim-signed emails.

phplist in v3.4.8 with ‘phpmailer 6’ or v3.4.7 with ‘phpmailer 5’ behaves in similar way.
I thought the new version has not the same problem.

What is wrong with the config?

It looks as if the PHPMailer method DKIM_Sign is returning an empty string. Either openssl is not installed or the signing by openssl_sign() is failing.

The php-module openssl is installed, using php 7.2.

I inserted the PEM-formated string in var $DKIM_private_string of PHPMailer.php. No CRLF only one long string. The variable $DKIM_private stays empty.

Probably something is not correct?

@massi there is an example of how to use DKIM in the phpmailer repository. Perhaps you can try to get that working, as it then rules out phplist. See

found the solution,
in file PHPMailer.php correct format of private text string is:
public $DKIM_private_string = ‘-----BEGIN RSA PRIVATE KEY-----’.PHP_EOL.’+++your-private-key+++’.PHP_EOL.’-----END RSA PRIVATE KEY-----’.PHP_EOL;

I’m interested to know how you configured, because I also have another system that works with DKIM but when I configure phplist with the same settings, phplist doesn’t send anything anymore.

Here are my parameters in /lists/admin/PHPMailer/class.phpmailer.php :
[‘dkim’][‘selector’] = ‘s1’; -> public $DKIM_selector
[‘domain’] = ‘’; -> public $DKIM_domain
[‘privkey’] = ‘/home/clients/blablablabla/’; -> public $DKIM_private

I don’t understand what I’m doing wrong.
Could you help me, please?

I edit the file PHPMailer6/src/PHPMailer.php directly.

like this:

public $DKIM_selector = ‘selector sting’;
public $DKIM_identity = ‘’;
public $DKIM_passphrase = ‘’;
public $DKIM_domain = ‘’;
public $DKIM_copyHeaderFields = false;
public $DKIM_extraHeaders = [];
public $DKIM_private = ‘’;
public $DKIM_private_string = ‘-----BEGIN RSA PRIVATE
KEY-----’.PHP_EOL.’###KEYVALUE no crlf###’.PHP_EOL.’-----END RSA PRIVATE

Alternatively you set in $DKIM_private the path to the key file and
$DKIM_private_string keeps empty.

Everything mentioned above is not very wise, as you have to change the
file every time after an update.

I’d recommend the developers of phplist to integrate this DKIM variables
into config.php as standard.

That would be awesome.

@massi You should be able to set these values in a plugin which would avoid you having to modify the file for each new release of phplist.

You can use the messageHeaders() method to set the DKIM variables because they are defined as public.

class DkimPlugin extends phplistPlugin
    public function messageHeaders($phpmailer)
        $phpmailer->DKIM_selector = ...
        $phpmailer->DKIM_identity = ...
        $phpmailer->DKIM_passphrase = ...
        $phpmailer->DKIM_domain = ...
        $phpmailer->DKIM_copyHeaderFields = ...
        $phpmailer->DKIM_extraHeaders = ...
        $phpmailer->DKIM_private = ...
        $phpmailer->DKIM_private_string = ...

        return [];

Thank you very much!
I did this and it’s better because the message is sent without error but without DKIM signature either :frowning:
And I don’t understand why and I don’t understand how to do…

You need to create a file in the admin/plugins directory, say DkimPlugin.php, then enable the plugin on the Manage Plugins page.

    class DkimPlugin extends phplistPlugin
        public function messageHeaders($phpmailer)
            $phpmailer->DKIM_selector = 'default';
            $phpmailer->DKIM_identity = '';
            $phpmailer->DKIM_passphrase = '';
            $phpmailer->DKIM_domain = '';
            $phpmailer->DKIM_copyHeaderFields = true;
            $phpmailer->DKIM_extraHeaders = [];
            $phpmailer->DKIM_private = '';
            $phpmailer->DKIM_private_string = <<<'END'

            return array();
1 Like

Many thanks, but it doesn’t work.
I adapt DKIM_selector, DKIM_identity, DKIM_domain, DKIM_private and empty DKIM_private_string and the result is :

Le message de test a été envoyé à: Échec

@duncanc : didn’t you forget ’ and ’ around this :



Edit : Even if I empty the DKIM_private variable and enter my full private key, it doesn’t work : I have the same “Echec” message.

@AlainR The way that I laid out the code is correct. phpmailer calculated the signature and added it to the email

DKIM-Signature: v=1;; s=default;
 a=rsa-sha256; q=dns/txt; t=1589964340; c=relaxed/simple;

You need to show exactly what you have changed in that code.

Thank you very much.
I cannot see in source code, because no mail is sent, I only have this message when I test sending a newsletter :

Le message de test a été envoyé à: Échec
and no mail is sent.

I have the same message when I parameter in /lists/admin/PHPMailer/class.phpmailer.php

And when I edit the file PHPMailer6/src/PHPMailer.php directly, I can send a newsletter test, but I cannot see DKIM-Signature in the source code of the received mail…

Thank you duncan for the plugin code. I modified my setup with DkimPlugin.php and it works.

Thanks for the DkimPlugin works like a charm :slightly_smiling_face:

1 Like