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; d=mydom.com; s=dkimsel;
a=rsa-sha256; q=dns/txt; l=30; t=1573568421; c=relaxed/simple;
h=Date:To:From:Subject:Message-ID:Content-Type;
i=sender@mydom.com;
bh=qw8RdF6sfjj2XXXXXXXXYYYYYYJ5C5mav6ijQn4kYgctWY=;
b=

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 https://github.com/PHPMailer/PHPMailer/tree/master/examples

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;

Hello.
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’] = ‘domain.com’; -> public $DKIM_domain
[‘privkey’] = ‘/home/clients/blablablabla/s1.domain.com.pem’; -> public $DKIM_private

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

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

like this:

public $DKIM_selector = ‘selector sting’;
public $DKIM_identity = ‘@domain.com’;
public $DKIM_passphrase = ‘’;
public $DKIM_domain = ‘domain.com’;
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
KEY-----’.PHP_EOL;

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.

<?php
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.

    <?php
    class DkimPlugin extends phplistPlugin
    {
        public function messageHeaders($phpmailer)
        {
            $phpmailer->DKIM_selector = 'default';
            $phpmailer->DKIM_identity = 'xxxxx@dcameron.me.uk';
            $phpmailer->DKIM_passphrase = '';
            $phpmailer->DKIM_domain = 'dcameron.me.uk';
            $phpmailer->DKIM_copyHeaderFields = true;
            $phpmailer->DKIM_extraHeaders = [];
            $phpmailer->DKIM_private = '';
            $phpmailer->DKIM_private_string = <<<'END'
-----BEGIN RSA PRIVATE KEY-----
MIICXAIBAAKBgQDCbcI6roYwtvNfXkK0QRccffcfoaNsKuTrsEtTuxtWBqmt+hYa
...
jHKssU9GSF0iEkWdGQFbE4yF/FVlZWl/f52pyF70R8g=
-----END RSA PRIVATE KEY-----
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é à: alainrxxxx@xxxxxxx.xxx Échec

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

<<<'END'
-----BEGIN RSA PRIVATE KEY-----
MIICXAIBAAKBgQDCbcI6roYwtvNfXkK0QRccffcfoaNsKuTrsEtTuxtWBqmt+hYa
...
jHKssU9GSF0iEkWdGQFbE4yF/FVlZWl/f52pyF70R8g=
-----END RSA PRIVATE KEY-----
END

??

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; d=dcameron.me.uk; s=default;
 a=rsa-sha256; q=dns/txt; t=1589964340; c=relaxed/simple;
 h=Date:To:From:Subject:Message-ID:MIME-Version:Content-Type;
 i=xxxxxxx@dcameron.me.uk;
 bh=mEeadZW53qVf9B78kjlwei389nG6q4ZZXbdL8xqgK7w=;
 b=m23jRcimIxpCxu43OnNzoCIz6T+jhgy2n+Q+OxVcg0QI5FYt2W8TEBcNV9YWltRDdqE/H9wlr
 +KiXYWhYUanacFMDnCgNz+UTktRa5khBFlStBAhGCnhKLWC/KukcpLxmz1BiiiyCFi5OkuR1X
 F/uUchu28azW2Fa7n9gSxYYn4= 

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é à: alainrxxxx@xxxxxxx.xxx É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