メールサーバをちゃんとする
- 28. 5.Webアプリ送信方法をちゃんとする
●
豆知識
web-app → MTA → 外のMTA(Gmailとか) → 受信者
突然のアカウント停止!
→ Gmailから「535 authentication failed 」
→ 5xx系エラーだからキューに溜まらない?
postfixの粋な計らいにより例外的にキューに入れて
defer扱いにしてくれる
(smtp_sasl_auth_soft_bounceオプションがデフォルトyes)
postfix△!
- 31. 6.まとめ
●
SMTPを確認する
⇒expectとかで工夫するとそんなに面倒じゃない
require 'pty'
require 'expect'
describe "mail" do
it "relay access denied" do
PTY.spawn("telnet mail.example.com 25") do |r,w|
w.sync = true
r.expect(/ESMTP Postfix/) { w.puts "HELO postfix" }
r.expect(/^250/) { w.puts "MAIL FROM: test@example.com" }
r.expect(/^250/) { w.puts "RCPT TO: hoge@example.com" }
r.expect(/^554/) { w.puts "QUIT" }
r.readline.match(/Relay access denied/)
end
end
end