カテゴリー
misc

Plus Addressing

Gmail の便利な機能のうちの一つにメールアドレスのエイリアスを勝手に作れるって機能ってのがあります。この機能は spam 避けというか、どこのサイトからアドレスが漏れたかを計るのに便利なので結構愛用してて、今や Gmail を使う最大の理由といってもいいぐらいの機能だったりします。で、この機能は Gmail の独自機能だと思ってたんですが、先日 irc で sendmail ではデフォルトで有効化されてる的な話を聞いたので、じゃあ postfix ではどうなのかしらん、と調べてみました。

しかし + とか検索するには向かない単語だよなー、とか思いつつてきとーに postfix plus symbol あたりで検索すると stackoverflow の記事がヒット。読んでみると

Yeah, postfix is the right place. Look at recipient_delimiter in the postconf docs:

recipient_delimiter (default: empty)

The separator between user names and address extensions (user+foo). See canonical(5), local(8), relocated(5) and virtual(5) for the effects this has on aliases, canonical, virtual, relocated and on .forward file lookups. Basically, the software tries user+foo and .forward+foo before trying user and .forward.

Example:

recipient_delimiter = +

じゃあってんで /Library/Server/Mail/Config/postfix/main.cf を覗いてみると

# ADDRESS EXTENSIONS (e.g., user+foo)
#
# The recipient_delimiter parameter specifies the separator between
# user names and address extensions (user+foo). See canonical(5),
# local(8), relocated(5) and virtual(5) for the effects this has on
# aliases, canonical, virtual, relocated and .forward file lookups.
# Basically, the software tries user+foo and .forward+foo before
# trying user and .forward.
#
# recipient_delimiter = +

しっかり書いてあった(笑)。なのでコメントアウトされてる recipient_delimiter を有効化して

sudo /Applications/Server.app/Contents/ServerRoot/usr/sbin/serveradmin stop mail
sudo /Applications/Server.app/Contents/ServerRoot/usr/sbin/serveradmin start mail

とメールサービス一式を再起動して goro+hoge@example.com 的なメールを送ってみたところ、何事もなく goro@example.com に配送されました。万歳。

そんなわけで OS X Server というか Postfix でもこの機能(Plus Addressing と呼ぶみたい?)が使えるよ、というお話でした。たまーに + が付いたアドレスを不正とするサービスがあるので、ここをカスタマイズできるというのが一番のポイントなのかもしれません。 RFC 的に問題がなくて使えそうな記号ってーとなにかなー?

記録のために長々と書いてきたけど、要約すると

となるのでなんだかなー、という気がしないこともない(笑

コメントを残す