今現在私は、mailerを使い、メールを送信しようと考えています。(done.html.erbというページが開いた時に送られるようにしたいと考えています)しかし、ターミナルでは送られたような動きがあるのですが、実際はメールが送れていない状態になっています。もしわかるかたがいらしたら、教えていただきたいです。
terminal
1Started GET "/done" for ::1 at 2019-06-18 15:34:05 +0300 2Processing by TouristsController#done as HTML 3 Rendered tourist_mailer/tourist_payment_mail.html.erb within layouts/mailer (0.2ms) 4 Rendered tourist_mailer/tourist_payment_mail.text.erb within layouts/mailer (0.1ms) 5 6TouristMailer#tourist_payment_mail: processed outbound mail in 34.4ms 7 8Sent mail to #{@tourist.email} (604.0ms) 9Date: Tue, 18 Jun 2019 15:34:05 +0300 10From: ********@gmail.com 11To: #{@tourist.email} 12Message-ID: <5d08da3d9615f_70e73fc18f43e48823670@********-no-MacBook-Air.local.mail> 13Subject: =?UTF-8?Q?=E3=81=8A=E5=95=8F=E3=81=84=E5=90=88=E3=82=8F=E3=81=9B?= 14Mime-Version: 1.0 15Content-Type: multipart/alternative; 16 boundary="--==_mimepart_5d08da3d9455c_70e73fc18f43e488235de"; 17 charset=UTF-8 18Content-Transfer-Encoding: 7bit 19 20 21----==_mimepart_5d08da3d9455c_70e73fc18f43e488235de 22Content-Type: text/plain; 23 charset=UTF-8 24Content-Transfer-Encoding: base64 25 26IzxUb3VyaXN0c0NvbnRyb2xsZXI6MHgwMDdmODMyNDFkOGQ2MD4g5qeY44GL 2744KJ5ZWP44GE5ZCI44KP44Gb44GM44GC44KK44G+44GX44Gf44CCDQogDQog 2844O744GK5ZWP44GE5ZCI44KP44GbDQogDQojPFRvdXJpc3RzQ29udHJvbGxl 29cjoweDAwN2Y4MzI0MWQ4ZDYwPg0KDQo= 30 31----==_mimepart_5d08da3d9455c_70e73fc18f43e488235de 32Content-Type: text/html; 33 charset=UTF-8 34Content-Transfer-Encoding: quoted-printable 35 36<html>=0D 37 <body>=0D 38 <!doctype html>=0D 39<html lang=3D"ja">=0D 40 <head>=0D 41 <meta content=3D"text/html; charset=3DUTF-8" />=0D 42 </head>=0D 43 <body>=0D 44 <h2>#<TouristsController:0x007f83241d8d60> =E6=A7=98</h2>=0D 45 <hr />=0D 46 <p>=0D 47 =E3=81=93=E3=82=93=E3=81=AB=E3=81=A1=E3=81=AF=EF=BC=81 #<Tourists= 48Controller:0x007f83241d8d60>=E3=81=95=E3=82=93=EF=BC=81</p>=0D 49 <hr />=0D 50 </body>=0D 51</html>=0D 52=0D 53 </body>=0D 54</html>=0D 55 56----==_mimepart_5d08da3d9455c_70e73fc18f43e488235de--
config/environment/development.rb
config.consider_all_requests_local = true config.action_controller.perform_caching = false config.action_mailer.delivery_method = :smtp config.action_mailer.smtp_settings = { address: 'smtp.gmail.com', port: 587, domain: 'smtp.gmail.com', user_name: '******@gmail.com', password: '**********', authentication: 'plain', enable_starttls_auto: true }
controller/tourist/done.controller.rb
def done TouristMailer.tourist_payment_mail(self).deliver_now end
application_mailer.rb
class ApplicationMailer < ActionMailer::Base default from: "******@gmail.com" layout 'mailer' end
tourist_mailer.rb
class TouristMailer < ApplicationMailer default from: '<*******:@gmail.com>' def tourist_payment_mail(tourist) @tourist = tourist mail( from: '<******@gmail.com>', to: '<#{@tourist.email}>', subject: 'お問い合わせ' ) end end
tourist_payment_mail.html.erb
mailers/tourist_payment_mail.html.e<!doctype
1<html lang="ja"> 2 <head> 3 <meta content="text/html; charset=UTF-8" /> 4 </head> 5 <body> 6 <h2><%= @tourist %> 様</h2> 7 <hr /> 8 <p> 9 こんにちは! <%= @tourist %>さん!</p> 10 <hr /> 11 </body> 12</html> 13
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/06/18 16:10
2019/06/18 23:47
2019/06/19 12:47
2019/06/19 15:17
2019/06/19 16:56 編集
2019/06/19 22:01
2019/06/20 12:05
2019/06/20 13:13
2019/06/20 16:34
2019/06/21 00:50