Phpmailer use dkim

不想你离开。 提交于 2019-12-04 19:45:26

For anybody who is trying to set this up, I've just 'resolved' the PHPMailer DKIM issue, which in effect allows the DKIM signature to be "signed-by:mydomain.com" by following the steps below:

  1. Create Keys
    I used http://dkimcore.org/tools/ to create the necessary keys. Take the raw private key and paste everything from --BEGIN to END-- and save it to a .txt file named private.key (without the *.txt).

    I did the same thing with the public key, for a personal backup copy(in case I need to retrieve it later) and saved it as public.key. ~again this is just for a backup copy.

  2. Add Files
    Take the two files that you just created and add them to your server/site, for example in the Apache > Conf folder.

  3. Add TXT Record to your domains DNS settings
    Using the Public Key, you will need to create a TXT Record in your domains DNS settings. The public keys going to look something like this:

1450071.mydomain._domainkey.mydomain.com:v=DKIM1;p=EBAQUAA4GNADCBiQKBgQC2uPmYVUJZvxxoYQqyygJMP0jqRKQLJ2QRN1k1HLrNCc13yK7ReDY3KmuZH+pgUNzXpfKHz0PGVLTMUAKpsqAPtkMfll8DSZawrFrny/jQIzEc03gTrEKCwp/k0iaL/Pwcha7pZEiN+wIDA


The Host Name: 1450071.mydomain._domainkey

The Value: v=DKIM1;p=EBAQUAA4GNADCBiQKBgQC2uPmYVUJZvxxoYQqyygJMP0jqRKQLJ2QRN1k1HLrNCc13yK7ReDY3KmuZH+pgUNzXpfKHz0PGVLTMUAKpsqAPtkMfll8DSZawrFrny/jQIzEc03gTrEKCwp/k0iaL/Pwcha7pZEiN+wIDA

The TTL: 1 Hour(3600)


4. Add the following DKIM lines to PHPMailer *after the setFrom

$mail->setFrom($from, $from_name);

..

$mail->DKIM_domain = 'mydomain.com';
$mail->DKIM_private = 'path/to/your/private.key>';
$mail->DKIM_selector = '1450071.mydomain'; //Prefix for the DKIM selector
$mail->DKIM_passphrase = ''; //leave blank if no Passphrase
$mail->DKIM_identity = $mail->From;

Final result: Success!

i've solved by adding $mail->Encoding = "base64"; To phpmailer array.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!