PHPMailer + DKIM. Re-use DA private key?

webunity

Verified User
Joined
Sep 23, 2014
Messages
49
Apparently, PHPMailer supports signed messages using DKIM:
https://github.com/PHPMailer/PHPMailer/blob/master/examples/DKIM_sign.phps

Assuming i have a domain with a DKIM entry 'x', i need to have the private key, according to the source code:
PHP:
//See the DKIM_gen_keys.phps script for making a key pair -
//here we assume you've already done that.
//Path to your private key:
$mail->DKIM_private = 'dkim_private.pem';

Which file do i need to use for this? Would that be:
/usr/local/directadmin/data/users/[user]/domains/[domain].[ext].key

Second question would off course then be how to read/access this key in my PHP scripts, but i assume a symlink (outside the web-accessible space) should be something i can test, e.g.
/home/[user]/domains/[domain].[ext]/dkim.key with ownership to the user?

An alternative option would be to create a second DKIM entry with a custom selector and have PHPMailer use that instead, but that would be my alternative option.
 
Last edited:
Hello,

If you have DKIM enabled on your server, then all outgoing emails should be signed with exim and you don't need to use PHPMailer for this.

If you still want PHPMailer to sign emails you need to create another key, PHP can not read anything under /etc/virtual/, it is the place where dkim keys are hosted.

/etc/virtual/domain.com/dkim.private.key
 
Back
Top