複数アプリを動かしている場合、アプリ毎にメールアドレスが欲しくなることがあります。
今回はpostfixのvirtual domain、virtual aliasを使って実現しました。1つのサーバ(host名:x.s21g.com)で、a.s21g.com, b.s21g.comのメール受信ができるようになります。流れとしては、

  1. satoko@b.s21g.comで受信したメールを
  2. satoko_at_b@a.s21g.comに転送
  3. それをscript/runncerで処理ということになります。

###mailnameの用意
myoriginパラメータで使う名前を設定します。
shell>>

cat /etc/mailname

a.s21g.com
<<--

###virtual aliasesの用意
メール受信時どういう処理をするかです: railsの場合script/runnerに食わせます。
PATHはそれぞれ書き換えてください。
shell>>

cat /etc/aliases

postmaster: root

#post_at_b: "| cat $1 > /tmp/mail_test.txt" #test用コード
post_at_b: "| /PATH_TO_RUBY/ruby /PATH_TO_RAILS_ROOT/script/runner -e production 'TestMailer.receive(STDIN.read)'"
<<--

###virtual domainの用意
virtual domainに来た場合どうするかを個別を書きます。
shell>>

cat /etc/postfix/virtual

b.s21g.com anything
post@b.s21g.com post_at_b
<<--

###postfixの設定を変更
mydestinationにb.s21g.comを設定、myorigin, virtual alias、virtual domainも指定します。

shell>>
#/etc/postfix/main.cf
mydestination = localhost, localhost.localdomain, localhost, b.s21g.com
myorigin = /etc/mailname
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
virtual_alias_maps = hash:/etc/postfix/virtual
<<--

###各設定を反映
shell>>

postalias /etc/aliases

postmap /etc/postfix/virtual

/etc/rc.d/init.d/postfix restart

<<--

(注意) a.s21g.comはDNSに登録してください。メール送信時、インターネット上でDNSが牽ける名前か相手サーバからチェックされており、その時点で蹴られてしまうからです。
(注意) スパムに使われないようにリレーを設定します:main.cf
relayhost =
mynetworks = 127.0.0.0/8

###Refs
http://blog.s21g.com/articles/569
http://www.tmtm.org/postfix/tutorial/index.html
http://furukawa.blogdns.com/furukawa/2006/04/postfix.html
http://www.jitaku-server.net/postfix_virtual_domain.html

posted by satoko satoko on Tue 13 May 2008 at 16:57 with 0 comments
Contents rssrss
NSAssertやNSLogを無効にする:-DNS_BLOCK_ASSERTIONS=1とNS_BLOCK_ASSERTIONS
GDBでview.frameを表示させる
Core Animationについてのリンク集
[iPhone] new BSDライセンスについてライセンス引用のメモ
Implementing a Container View Controller in UIViewController Class Reference
UITableView用のNSIndexPathの作り方
Xcodeのテンプレート、View-based ApplicationとWindow-based Applicationの違い
CopyOnSelectのLion対応
Xcode4のCode Snippetsを別のPCに移動する+gitで管理する
[iPhone] Singleton: iOS4以降はGCDのdispatch_onceを使う
Tags
iphone開発gitIBInterfaceBuilderiOSSIMBLSnippetsterminaltwitterxcodeXcode4
Comments rssrss
guest guest: Muchos turistas buscan la mejor forma de llegar a ... 05/30 03:19
guest guest: San Antonio de Areco es conocido como la cuna de l... 05/27 19:47
guest guest: Optimizar el tiempo durante un viaje de negocios e... 05/18 00:46
guest guest: Para muchos turistas, el transporte publico y la l... 05/15 18:22
Services from s21g
MagicBag
MagicBagは、Cloudflare R2やS3互換ストレージをMacのFinderから扱えるファイル同期クライアントです。
アンテナショップめぐり
東京にある全国のアンテナショップ、イベント、特産品を地図や条件から探せるサービスです。
YOMU Web小説リーダー
YOMUは、Web小説の読み上げに特化したiPhoneアプリです。
補助探
公開されている補助金・助成金情報を集約し、条件に合う制度を探しやすくするサービスです。
jotter.me
jotter.meは、考えやアイデア、情報を書き留めるためのノートサービスです。