Last active
September 21, 2024 03:23
-
-
Save kawaz/e80f3757e1607048da8bebe1dd4352f5 to your computer and use it in GitHub Desktop.
postfixからAmazon SESに雑にメールをリレーさせる設定テンプレ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ローカルで発生したメールを全部SESにリレーして送信する | |
sender_canonical_maps=regexp:/etc/postfix/sender_canonical_maps.regexp | |
sender_dependent_relayhost_maps=hash:/etc/postfix/sender_dependent_relayhost_maps regexp:/etc/postfix/sender_dependent_relayhost_maps.regexp | |
smtp_sasl_auth_enable=yes | |
smtp_sasl_password_maps=hash:/etc/postfix/smtp_sasl_password_maps regexp:/etc/postfix/smtp_sasl_password_maps.regexp | |
smtp_sasl_security_options=noanonymous | |
smtp_sender_dependent_authentication=yes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# sender_canonical_maps では、sender (envelope-from) の書き換えを行う。 | |
# ・上から順に評価されてマッチしたらそこで終わる | |
# ・書き換えたくないsenderは先にマッチさせて元のまま返すのがポイント | |
# ・適当なドメインのsenderを validation 済みドメインに書き換える事でアプリ側は細かい事を気にせずメール送信が出来る | |
# sender が @example.com なメールは書き換えない(=元のママに書き換える) | |
/(.*@example\.com)$/ ${1} | |
# sender がドット無しホスト名なら元のホスト名情報を残しつつ @example.com に書き換える | |
/(.+)@([^\.]+)$/ ${1}+${2}@example.com | |
# sender がローカル系ホスト名なら元のホスト名情報を残しつつ @example.com に書き換える | |
/(.+)@(.+\.(local|localdomain|internal))$/ ${1}+${2}@example.com | |
# sender がどんなドメインでも元のホスト名情報を残しつつ @example.com に書き換える | |
#/(.+)@(.+)$/ ${1}+${2}@example.com |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# sender_dependent_relayhost_maps では sender アドレスに応じてリレー先を変更することができる | |
# ・上から順にマッチして見つけたらそこで評価終了 | |
# ・マッチしなければリレー先の変更はされない | |
# ・validation済みのsenderのみを選んでSESにリレーする事で無駄な拒否エラーを回避できる。 | |
# from が example.com なメールはSESにリレーする | |
/@([a-z0-9\.-]+\.)?example\.com$/ [email-smtp.ap-northeast-1.amazonaws.com]:587 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# SESリレー用のIAMユーザのパスワード | |
/@([a-z0-9\.-]+\.)?example\.com$/ AKXXXXX:PASSWORD |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment