2010年10月03日
■ 試用中の「さくらのVPS」からメールを送信する
さくらのVPSでは試用期間中はOB25P (外部へのSMTP接続) が設定されているため、メールを送信する事が出来ない。(多分spam対策)
これではroot宛のメールが受け取る事が出来ない、メールのテストが出来ないという問題があるため、別途用意したサーバ (以降 "中継サーバ") のSubmissionポートを利用して中継する方法を試してみた。
環境
- 送信元となるサーバ (送信サーバ)
- さくらのVPS (postfix-2.3.3) 試用期間中, fatechan.example.com [192.0.2.99]
- 中継に利用するサーバ (中継サーバ)
- 適当なサーバ (今回はさくらの専用サーバを利用, postfix-2.6.2), azunyan.example.com [192.0.2.100]
※ホスト名とIPアドレスは架空のものです。
設定
送信サーバの main.cf に以下のように記載すると、外部向けのメールは全て azunyan.example.com の submission ポートを利用する。("submission" の代わりに、直値で "587" と書いても良い。)
relayhost = azunyan.example.com:submission
DNSに登録していない場合は、hosts ファイルに書いて "[azunyan.example.com]:submission" またはIPアドレスそのまま "[192.0.2.99]:submission" のように書く。
中継サーバ (別途専用サーバを借りている) ではmaster.cfでSubmissionポートの設定を行っているところにmynetworksで送信サーバのアドレスを指定、"smtpd_client_restrictions" の項目には "permit_mynetworks" を加える。
submission inet n - n - - smtpd -o mynetworks=127.0.0.0/8,192.0.2.99 -o smtpd_sasl_auth_enable=yes -o smtpd_client_restrictions=permit_mynetworks,permit_sasl_authenticated,reject
設定が完了したら送信サーバ・中継サーバでそれぞれPostfixを再起動する。
# postfix reload
送信テスト
テストは送信サーバ・中継サーバで受信するドメイン以外のメールアドレスに対して送信テストを行う。(中継する動作のテストを行うため。) ここではGmailに対してテスト送信を行った。
% echo "azunyan peropero" | mail -s test *****************@gmail.com
ログ確認
送信元の maillog で "status=sent" を確認する。
Oct 3 15:38:31 fatechan postfix/pickup[16380]: EF58728E274: uid=500 from=<yasu> Oct 3 15:38:31 fatechan postfix/cleanup[16501]: EF58728E274: message-id=<20101003063831.EF58728E274@fatechan.example.com> Oct 3 15:38:32 fatechan postfix/qmgr[1538]: EF58728E274: from=<yasu@fatechan.example.com>, size=317, nrcpt=1 (queue active) Oct 3 15:38:37 fatechan postfix/smtp[16503]: EF58728E274: to=<****************@gmail.com>, relay=azunyan.example.com[192.168.2.100]:587, delay=5.1, delays=0.05/0.02/5.1/0.03, dsn=2.0.0, status=sent (250 2.0.0 Ok: queued as EB47E2674A1) Oct 3 15:38:37 fatechan postfix/qmgr[1538]: EF58728E274: removed
中継するサーバの maillog で "status=sent" を確認。
Oct 3 15:38:35 azunyan postfix/smtpd[57399]: connect from www****.sakura.ne.jp[192.0.2.99] Oct 3 15:38:35 azunyan postfix/smtpd[57399]: EB47E2674A1: client=www****.sakura.ne.jp[192.0.2.99] Oct 3 15:38:35 azunyan postfix/cleanup[57401]: EB47E2674A1: message-id=<20101003063831.EF58728E274@fatechan.example.com> Oct 3 15:38:35 azunyan postfix/smtpd[57399]: disconnect from www****.sakura.ne.jp[192.0.2.99] Oct 3 15:38:35 azunyan postfix/qmgr[56858]: EB47E2674A1: from=<yasu@fatechan.example.com>, size=523, nrcpt=1 (queue active) Oct 3 15:38:38 azunyan postfix/smtp[57402]: EB47E2674A1: to=<****************@gmail.com>, relay=gmail-smtp-in.l.google.com[74.125.53.27]:25, delay=2.2, delays=0.02/0.02/0.88/1.3, dsn=2.0.0, status=sent (250 2.0.0 OK 1286087919 t8si7787685wak.33) Oct 3 15:38:38 azunyan postfix/qmgr[56858]: EB47E2674A1: removed
問題無さそう。
- 18 http://pipes.yahoo.com/pipes/pipe.info?_id=3eebace824bb60a10f13c841c2c64478
- 15 http://www.google.co.jp/search?q=さくら+vps&num=30&hl=ja&safe=off&biw=1920&bih=955&source=lnms&tbs=mbl:1&ei=7hepTJvWL5DQcYDF6cMN&sa=X&oi=mode_link&ct=mode&ved=0CCEQ_AU&prmdo=1
- 10 http://www.google.co.jp/search?q=????????????VPS&hl=ja&client=firefox-a&rls=org.mozilla:ja-JP-mac:official&tbs=blg:1&ei=skSvTPuuEI7UvQOCr9CtBg&start=10&sa=N
- 9 http://www.google.co.jp/search?hl=ja&client=firefox-a&hs=X5k&rls=org.mozilla:ja:official&q=trac+フィード+plagger&aq=f&aqi=&aql=&oq=&gs_rfai=
- 8 http://www.google.co.jp/search?hl=ja&q=さくら+vps+メールサーバー+postfix&aq=f&aqi=&aql=&oq=&gs_rfai=
- 8 http://www.google.co.jp/search?sourceid=chrome&ie=UTF-8&q=さくらVPS+postfix
- 6 http://twitter.com/
- 6 http://www.google.co.jp/search?q=さくらVPS Postfix&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:ja:official&hl=ja&client=firefox-a
- 6 http://www.google.com/search?hl=ja&lr=lang_ja&ie=UTF-8&oe=UTF-8&q=さくら+VPS++SMTP&num=50
- 5 http://twitter.com/hirayasu
