私は、現在本番環境で、Amazon SESを導入し、お問い合わせページからメールを送るようにしたいと考えています。しかし、お問い合わせページからの送信がうまくいかない状態になっています。
試したこと
・ドメイン・メールの認証 完了済み✔︎
・Send a test emailは成功✔︎
・sending statics 送れてない✖︎
参考ページ
・https://qiita.com/tanakaworld/items/94f1ba66801100f6a44f
お問い合わせメール送信後のコンソールの状況
Terminal
1I, [2020-07-15T05:29:09.899337 #12692] INFO -- : Started GET "/contact" for 103.5.140.154 at 2020-07-15 05:29:09 +0000 2I, [2020-07-15T05:29:09.903009 #12692] INFO -- : Processing by CustomerController#contact as HTML 3I, [2020-07-15T05:29:09.905476 #12692] INFO -- : Rendered customer/contact.html.erb (2.0ms) 4I, [2020-07-15T05:29:09.905654 #12692] INFO -- : Completed 200 OK in 3ms (Views: 2.4ms | ActiveRecord: 0.0ms) 5I, [2020-07-15T05:29:36.914159 #12690] INFO -- : Started POST "/customer/confirm" for 103.5.140.154 at 2020-07-15 05:29:36 +0000 6I, [2020-07-15T05:29:36.917798 #12690] INFO -- : Processing by CustomerController#confirm as HTML 7I, [2020-07-15T05:29:36.917882 #12690] INFO -- : Parameters: {"utf8"=>"✓", "authenticity_token"=>"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$", "customer"=>{"name"=>"とし", "email"=>"$$$$$$$$$$$$$$$$$@gmail.com", "about"=>"投稿の件について", "message"=>"いつもお世話になっております。としです。"}, "commit"=>"同意して送信"} 8I, [2020-07-15T05:29:36.920949 #12690] INFO -- : Rendered customer/confirm.html.erb (2.5ms) 9I, [2020-07-15T05:29:36.921113 #12690] INFO -- : Completed 200 OK in 3ms (Views: 2.9ms | ActiveRecord: 0.0ms) 10I, [2020-07-15T05:29:39.715659 #12692] INFO -- : Started POST "/customer/thanks" for 103.5.140.154 at 2020-07-15 05:29:39 +0000 11I, [2020-07-15T05:29:39.719248 #12692] INFO -- : Processing by CustomerController#thanks as HTML 12I, [2020-07-15T05:29:39.719319 #12692] INFO -- : Parameters: {"utf8"=>"✓", "authenticity_token"=>"$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$", "customer"=>{"name"=>"とし", "email"=>"$$$$$$$$$$$$$$$@gmail.com", "about"=>"投稿の件について", "message"=>"いつもお世話になっております。としです。"}, "commit"=>"送信する"} 13I, [2020-07-15T05:29:39.720596 #12692] INFO -- : Rendered customer_mailer/received_email.html.erb within layouts/mailer (0.2ms) 14I, [2020-07-15T05:29:39.720885 #12692] INFO -- : Rendered customer_mailer/received_email.text.erb within layouts/mailer (0.0ms) 15D, [2020-07-15T05:29:39.722412 #12692] DEBUG -- : 16CustomerMailer#received_email: processed outbound mail in 2.5ms 17I, [2020-07-15T05:29:40.253488 #12692] INFO -- : 18Sent mail to $$$$$$$$$$$$$$$$$@gmail.com (531.0ms) 19D, [2020-07-15T05:29:40.253570 #12692] DEBUG -- : Date: Wed, 15 Jul 2020 05:29:39 +0000 20From: Testrooper <$$$$$$$$$$$$$$$$$@gmail.com> 21To: $$$$$$$$$$$$$$$@gmail.com 22Message-ID: <$$$$$$$$$$$$$$$$$$$$$$$$$$$$$> 23Subject: =?UTF-8?Q?$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ 24Mime-Version: 1.0 25Content-Type: multipart/alternative; 26 boundary="--==_mimepart_5f0e9443b01c8_31941079c10297c"; 27 charset=UTF-8 28Content-Transfer-Encoding: 7bit 29 30 31----==_mimepart_5f0e9443b01c8_31941079c10297c 32Content-Type: text/plain; 33 charset=UTF-8 34Content-Transfer-Encoding: base64 35 36$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ 37 38----==_mimepart_5f0e9443b01c8_31941079c10297c 39Content-Type: text/html; 40 charset=UTF-8 41Content-Transfer-Encoding: base64 42 43$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ 44 45----==_mimepart_5f0e9443b01c8_31941079c10297c-- 46
initializers/aws.rb
aws
1ActionMailer::Base.add_delivery_method( 2 :ses, 3 AWS::SES::Base, 4 access_key_id: '$$$$$$$$$$$$$$$', 5 secret_access_key: '$$$$$$$$$$$$$$$$$$$', 6 server: 'email.us-west-2.amazonaws.com' 7)
environments/production.rb
production
1 config.action_mailer.raise_delivery_errors = false 2 config.mailer_sender = 'Testrooper <$$$$$$$$$$$$$$$$$$@gmail.com>' 3 config.action_mailer.default_url_options = { host: '$$$$$$$$$$$$$$' } 4 config.action_mailer.delivery_method = :ses 5 config.action_mailer.smtp_settings = { :enable_starttls_auto => false }
customer_mailer.rb
mailer
1class CustomerMailer < ApplicationMailer 2 default from: "Testrooper <$$$$$$$$$$$$$$$$$$$$@gmail.com>" # 送信元アドレス 3 layout 'mailer' 4 5 def received_email(customer) 6 @customer = customer 7 mail( 8 to: 'Testrooper <$$$$$$$$$$$$$$$$$$$$$@gmail.com>', 9 subject: 'お問い合わせを承りました' 10 ) 11 end 12end
received_email.html.erb
view
1<!doctype html> 2<html lang="ja"> 3 <head> 4 <meta content="text/html; charset=UTF-8" /> 5 </head> 6 <body> 7 <p>Name: <%= @customer.name %></p> 8 <p>Email: <%= @customer.email %></p> 9 <p>Subject: <%= @customer.about %></p> 10 <p>Message: <%= @customer.message %></p> 11 <hr /> 12 </body> 13</html> 14