我試圖將我們的Rails應用程序切換到使用亞馬遜的SES服務進行電子郵件。該應用程序使用Ruby 1.8.6和Rails 2.2.2。亞馬遜SES:說它發送測試電子郵件,但他們沒有到達
SES需要的郵件使用TLS(SSL的加密風格),這是不是在Ruby中1.8.6的支持,但我發現寶石修補此,在這裏:https://github.com/seattlerb/smtp_tls
我測試從我的控制檯發送電子郵件,就像這樣:
options = {
:address => "email-smtp.eu-west-1.amazonaws.com",
:port => 587,
:user_name => "my-ses-smtp-username",
:password => "my-ses-smtp-password",
:authentication => :login
}
smtp = Net::SMTP.new options[:address], options[:port]
smtp.enable_starttls
smtp.start Socket.gethostname, options[:user_name], options[:password], options[:authentication] do |server|
server.send_message "subject: hello\nblah blah\n\n", "[email protected]", "[email protected]"
end
「[email protected]」和「[email protected]」都被驗證了SES和「ourdomain.com」是我們註冊的域名有。
我在SES的Sandbox模式下,使用他們自己的電子郵件測試控制檯發送了一些電子郵件到驗證的地址,這些郵件到達了。
SES上的統計頁面列出了一個發送的電子郵件,雖然下面的時間線圖實際上表示已經有6次發送和一次反彈。無論哪種方式,我希望看到一些事情,但沒有。
我已經把一些記錄到的Net :: SMTP,看看有什麼與上述要求發生,它看起來OK,從我有限的知識:
net/smtp.rb:672:in `check_response': res = "220 email-smtp.amazonaws.com ESMTP SimpleEmailService-2007935501 vtiBU5pQUlPZ3bAZIaZl\n", allow_continue = false
net/smtp.rb:648:in `getok': fmt = "EHLO %s"; args = ["max-thinkpad-linux"]
net/smtp.rb:672:in `check_response': res = "250-email-smtp.amazonaws.com\n250-8BITMIME\n250-SIZE 10485760\n250-STARTTLS\n250-AUTH PLAIN LOGIN\n250 Ok\n", allow_continue = false
net/smtp.rb:648:in `getok': fmt = "STARTTLS"; args = []
net/smtp.rb:672:in `check_response': res = "220 Ready to start TLS\n", allow_continue = false
net/smtp.rb:648:in `getok': fmt = "EHLO %s"; args = ["max-thinkpad-linux"]
net/smtp.rb:672:in `check_response': res = "250-email-smtp.amazonaws.com\n250-8BITMIME\n250-SIZE 10485760\n250-STARTTLS\n250-AUTH PLAIN LOGIN\n250 Ok\n", allow_continue = false
net/smtp.rb:672:in `check_response': res = "334 VXNlcm5hbWU6\n", allow_continue = true
net/smtp.rb:672:in `check_response': res = "334 UGFzc3dvcmQ6\n", allow_continue = true
net/smtp.rb:648:in `getok': fmt = "MAIL FROM:<%s>"; args = ["[email protected]"]
net/smtp.rb:672:in `check_response': res = "250 Ok\n", allow_continue = false
net/smtp.rb:648:in `getok': fmt = "RCPT TO:<%s>"; args = ["[email protected]"]
net/smtp.rb:672:in `check_response': res = "250 Ok\n", allow_continue = false
net/smtp.rb:672:in `check_response': res = "354 End data with <CR><LF>.<CR><LF>\n", allow_continue = true
net/smtp.rb:672:in `check_response': res = "250 Ok 0102015bd896c863-02370584-903e-4c64-b5a0-5c5c5dcc28c6-000000\n", allow_continue = false
net/smtp.rb:648:in `getok': fmt = "QUIT"; args = []
net/smtp.rb:672:in `check_response': res = "221 Bye\n", allow_continue = false
您是否成功認證?我在輸出中看不到清理的auth部分。 https://en.wikipedia.org/wiki/SMTP_Authentication – ddubs
驗證工作 - 如果我更改密碼,我會收到驗證失敗的消息。也許是因爲認證選項設置爲「登錄」,它看起來不同於你的期望? –