LoginSignup
4
10

More than 5 years have passed since last update.

PostifxでDKIM認証する

Last updated at Posted at 2015-12-20

プラグインのインストール

apt-get install opendkim opendkim-tools

設定ファイルの修正

vi /etc/opendkim.conf
以下が有効になるように修正する。

Syslog                  yes
LogWhy                  yes
UMask                   022
UserID                  opendkim:opendkim
Domain                  メールドメイン
KeyFile                 /etc/postfix/dkim/20151119.private
Selector                maildkim
SOCKET                  inet:8891@localhost
Mode                    sv
OversignHeaders         From
SignatureAlgorithm      rsa-sha256
Canonicalization        relaxed/simple
SigningTable            refile:/etc/postfix/dkim/SigningTable
KeyTable                refile:/etc/postfix/dkim/KeyTable
ExternalIgnoreList      refile:/etc/postfix/dkim/TrustedHosts
InternalHosts           refile:/etc/postfix/dkim/TrustedHosts

inetSocketの追加

vi /etc/default/opendkim
SOCKET="inet:8891@localhost" # listen on loopback on port 12345

DKIM鍵の作成

mkdir /etc/postfix/dkim

opendkim-genkey -D /etc/postfix/dkim -d メールドメイン -s maildkim
 ※maildkimはSelector名
/etc/postfix/dkim内に「maildkim.private」と「maildkim.txt」が作成される

リストファイルの作成

vi /etc/postfix/dkim/KeyTable
書き方
Selector名._domainkey.メールドメイン メールドメイン:Selector名:/etc/postfix/dkim/Selector名.private
例)
maildkim._domainkey.hoge.com hoge.com:maildkim:/etc/postfix/dkim/maildkim.private
vi /etc/postfix/dkim/SigningTable
書き方
*@メールドメイン     Selector名._domainkey.メールドメイン
例)
*@hoge.com     maildkim._domainkey.hoge.com
vi /etc/postfix/dkim/TrustedHosts
127.0.0.1
メールドメイン

postfix設定ファイル修正

vi /etc/postfix/main.cf
以下を追記する
#-------------------------------------#
# DKIM
#-------------------------------------#
milter_default_action = accept
milter_protocol = 2
smtpd_milters = inet:localhost:8891
non_smtpd_milters = inet:localhost:8891

postfix再起動

service postfix restart

DNSへ登録する

レコード情報の確認

cat /etc/postfix/dkim/maildkim.txt
20151119._domainkey     IN      TXT     ( "v=DKIM1; k=rsa; "
          "p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDfPR2a~

一般的なDNSサーバーへのレコード登録

20151119._domainkey.hoge.com    IN  TXT v=DKIM1; k=rsa; p=MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDfPR2a~
_adsp._domainkey.hoge.com   IN  TXT dkim=unknown
4
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
10