Sign Outgoing Emails With DKIM
Adds a DKIM signature to every email using a private key file and settings stored in wp-config.php, so receiving servers can verify your messages.
Opens WPIDE on
Code
add_action( 'phpmailer_init', function ( $phpmailer ) {
if ( ! defined( 'WPIDE_DKIM_DOMAIN' ) || ! defined( 'WPIDE_DKIM_SELECTOR' ) || ! defined( 'WPIDE_DKIM_PRIVATE_KEY' ) ) {
return;
}
if ( ! is_readable( WPIDE_DKIM_PRIVATE_KEY ) ) {
return;
}
$phpmailer->DKIM_domain = WPIDE_DKIM_DOMAIN;
$phpmailer->DKIM_selector = WPIDE_DKIM_SELECTOR;
$phpmailer->DKIM_private = WPIDE_DKIM_PRIVATE_KEY;
$phpmailer->DKIM_identity = $phpmailer->From;
if ( defined( 'WPIDE_DKIM_PASSPHRASE' ) ) {
$phpmailer->DKIM_passphrase = WPIDE_DKIM_PASSPHRASE;
}
} );
Notes
Define WPIDE_DKIM_DOMAIN, WPIDE_DKIM_SELECTOR and WPIDE_DKIM_PRIVATE_KEY (absolute path outside the web root) in wp-config.php and publish the public key in DNS. Does nothing until they are defined.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.