24

Currents i am using phpmailer to send mail's. now how its possible to send email in phpmailer with DKIM keys

i search in phpmailer Class file and i found the below code

    /**
     * DKIM selector.
     * @type string
     */
    public $DKIM_selector = '';

    /**
     * DKIM Identity.
     * Usually the email address used as the source of the email
     * @type string
     */
    public $DKIM_identity = '';

    /**
     * DKIM passphrase.
     * Used if your key is encrypted.
     * @type string
     */
    public $DKIM_passphrase = '';

    /**
     * DKIM signing domain name.
     * @example 'example.com'
     * @type string
     */
    public $DKIM_domain = '';

    /**
     * DKIM private key file path.
     * @type string
     */
    public $DKIM_private = '';

Can i know how its possible.

2
  • What specifically are you having trouble with? The comments seem fully explanatory. Commented Jun 28, 2014 at 4:02
  • I experimented with this but couldn't make it work. I opted for an OpenDKIM filter for Sendmail which has the advantage that all the outbound mail is signed Commented Jun 28, 2014 at 4:02

2 Answers 2

47
+50

If you take a look in the PHPMailer unit tests, there is an example of how to set up DKIM.

Here are the basics beyond what you already need to do to send a message (obviously change the domain, key path and selector to match your config, and add a passphrase if you use one); this also assumes that you are intending to sign using the same identifier as your From address:

$mail->DKIM_domain = 'example.com';
$mail->DKIM_private = '/path/to/my/private.key';
$mail->DKIM_selector = 'phpmailer';
$mail->DKIM_passphrase = '';
$mail->DKIM_identity = $mail->From;

When you send() the message (and not before), it will use these settings to generate a DKIM signature.

Sign up to request clarification or add additional context in comments.

12 Comments

Is the DKIM_selector always 'phpmailer' ?
Thanks for the help on this. For a full guide on how to setup DKIM before you get to this point i put together a guide yomotherboard.com/how-to-setup-email-server-dkim-keys
DKIM_identifier is now DKIM_identity (PHPMailer 5.2.13)
DKIM_selector is the selector key setup on your DNS TXT record. It's not always phpmailer as in the example.
To use a private key string instead of setting a path to a file, you can simply specify $mail -> DKIM_private_string property on your phpMailer object.
|
2