Устанавливаем
apt-get install opendkim
Задаём spf запись
v=spf1 mx ip:our_ip -all
Конфиг /etc/opendkim.conf
SubDomains Yes RemoveARAll Yes RemoveOldSignatures Yes SendReports Yes Canonicalization relaxed/relaxed Mode sv UserID opendkim:opendkim Syslog Yes SyslogSuccess Yes LogWhy Yes KeyTable /etc/opendkim/KeyTable SigningTable refile:/etc/opendkim/SigningTable ExternalIgnoreList refile:/etc/opendkim/TrustedHosts InternalHosts refile:/etc/opendkim/TrustedHosts #Nameservers 172.31.31.161 PidFile /var/run/opendkim/opendkim.pid Socket inet:10021@localhost ReportAddress "DKIM Error Postmaster" <>
В файл /etc/opendkim/TrustedHosts добавляем хосты, которым можно отсылать почту
127.0.0.1 192.168.0.0/16
В файл /etc/opendkim/KeyTable прописываем селектор домена и приватный ключ который использовать например mail25
mail25._domainkey.example.com example.com:mail25:/etc/opendkim/keys/example.com/mail25.private
В файл /etc/opendkim/SighingTable прописываем адреса и их селекторы
*@example.com mail25._domainkey.example.com
Генерим приватны ключ
opendkim-genkey -s mail25 -d example.com
Будет создан фал mail25.txt с TXT DNS записью, её надо внести в dns
mail25._domainkey IN TXT "v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC5N3lnvvrYgPCRSoqn+awTpE+iGYcKBPpo8HHbcFfCIIV10Hwo4PhCoGZSaKVHOjDm4yefKXhQjM7iKzEPuBatE7O47hAx1CJpNuIdLxhILSbEmbMxJrJAG0HZVn8z6EAoOHZNaPHmK2h4UUrjOG8zA5BHfzJf7tGwI+K619fFUwIDAQAB" ; ----- DKIM key mail for example.com
Добавляем строку в файл /etc/default/opendkim
SOCKET="inet:12301@localhost"
В /etc/postfix/main.cf
smtpd_milters = inet:localhost:12301 non_smtpd_milters = inet:localhost:12301
Меняем владельца конфигов и ключей
chown opendkim: -R /etc/opendkim
Перезапускаем сервисы
service postfix restart service opendkim restart
Как проверить:
- В логах будет строка
DKIM-Signature field added (s=mail25, d=examle.com)
- В письме будут строки
dkim=pass header.i=@examlpe.com header.s=mail25 header.b="BwTnvr1/"; spf=pass (google.com: domain of eshop@examlpe.com designates 0.0.0.0 as permitted sender) smtp.mailfrom=eshop@examlpe.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=examlpe.com
- Можно проверить тут https://www.dmarcanalyzer.com/dkim/dkim-check/
0 Comment