ruby-on-rails-4 – Action :: Mailer不向收件人发送邮件
我正在尝试在查看个人资料时向用户发送邮件.即当用户点击特定联系人的节目时,该联系人将收到关于个人资料视图的通知.我没有得到任何错误.但是我触发了邮件有一些延迟.它也可以在控制台中正常工作.但邮件没有发送给收件人.
这是我到目前为止所尝试的. mailer.rb: class CustomerSupport < ActionMailer::Base def customer_support(contact) mail :to => contact.email,:from => "sugukvs92@gmail.com",:subject => "profileviews" end end 为setup_mail.rb ActionMailer::Base.delivery_method = :smtp ActionMailer::Base.smtp_settings = { :address => "smtp.gmail.com",:port => 587,:domain => "gmail.com",:user_name => "sugukvs92",:password => "**************",:authentication => "plain",:enable_starttls_auto => true } controller.rb def show @contact = Contact.find(params[:id]) CustomerSupport.customer_support(@contact).deliver end 我是否需要添加任何gem才能实现此功能? development.log 在2014-07-16 10:48:07 0530开始获取127.0.0.1的“/ contacts / 3” CustomerSupport#customer_support:在11.9ms内处理出站邮件 Sent mail to suganya.gnanasekar@in.reportbee.com (1797.4ms) Date: Wed,16 Jul 2014 10:48:07 +0530 From: sugukvs92@gmail.com To: suganya.gnanasekar@in.reportbee.com Message-ID: <53c60b0f7e609_b993ec57901998d@ameex.mail> Subject: customer support from Report Bee Mime-Version: 1.0 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit <html> <head> <meta content='text/html; charset=UTF-8' http-equiv='Content-Type' /> </head> <body> <h1>Welcome to example.com,</h1> <p> You have successfully signed up to example.com,</p> <p> To login to the site,just follow this link: </p> <p>Thanks for joining and have a great day!</p> </body> </html> Rendered contacts/show.html.erb within layouts/application (0.6ms) Completed 200 OK in 1829ms (Views: 16.2ms | ActiveRecord: 0.2ms) 解决方法
我尝试使用以下代码引发运行时错误.
我添加了这些行 config.action_mailer.perform_deliveries = true config.action_mailer.raise_delivery_errors = true 我犯了一个非常愚蠢的错误.我在我的gmail帐户中打开了两步验证,我用它来默认:来自.所以我禁用了它,我的应用程序正常运行. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |