10
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

迷惑メール対策 (Sender address reject)

Last updated at Posted at 2015-02-12

参考

現在の設定確認

未設定の場合
# main.cfで追加設定したもの
$ postconf -n | grep smtpd_sender_restrictions
smtpd_sender_restrictions =

# 初期値 (postconf -n で出力がなかった場合こちらでも確認)
$ postconf -d | grep smtpd_sender_restrictions
smtpd_sender_restrictions =

設定を行う(hash:を使う場合)

/etc/postfix/main.cf
smtpd_sender_restrictions = 
    check_sender_access hash:/etc/postfix/access
/etc/postfix/access
bma.rec.mpse.jp	REJECT
vp.pl	REJECT
bxz.jp	REJECT
bis-news.com	REJECT
nextsb19.org	REJECT
omence.asia	REJECT
jp365.asia	REJECT
japan-onlline-shop.mobi	REJECT
blue	REJECT
academy-sophrology.biz	REJECT
seikotuin88.org REJECT

受信を拒否したいドメイン名を列挙。
ここのものはメールアドレスの末尾に該当する。(/blue$/)

  • 試しに blue@myaddress.com 宛にメール送ってみたところ、これまで通り送信できた。
  • 試しに blue@myaddress.com からメールを受信してみたところ、これまで通り送信できた。
/etc/postfix/access.dbを更新
sudo /usr/sbin/postmap access
リスタート
sudo /etc/init.d/postfix restart

運用

追加をしたい場合、/etc/postfix/accessに追記し同様にpostmap accessする。
(その際/etc/init.d/postfix restartは不要)

正規表現での指定(regexp:を使う場合)

/etc/postfix/access
/41news23.org$/    REJECT
/blue$/ REJECT
/red$/  REJECT
/pink$/ REJECT
/mobi$/ REJECT
/etc/postfix/main.cf
smtpd_sender_restrictions = 
    check_sender_access regexp:/etc/postfix/access

ログ

smtpd_helo_restrictions でブロックした場合 (今回の設定例には載せていないが)

Nov 13 05:53:02 mail01 postfix/smtpd[21883]: NOQUEUE: reject: RCPT from unknown[122.231.33.216]: 554 5.7.1 : Helo command rejected: Access denied; from=<1741873947@qq.com> to= proto=SMTP helo=

smtpd_sender_restrictions でブロックした場合

Nov 13 05:53:05 mail01 postfix/smtpd[21786]: NOQUEUE: reject: RCPT from unknown[121.234.230.209]: 554 5.7.1 386909471@qq.com: Sender address rejected: Access denied; from=386909471@qq.com to=root@sample.com proto=SMTP helo=

10
11
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
10
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?