我正在尝试在查看个人资料时向用户发送邮件.即当用户点击特定联系人的节目时,该联系人将收到关于个人资料视图的通知.我没有得到任何错误.但是我触发了邮件有一些延迟.它也可以在控制台中正常工作.但邮件没有发送给收件人.
这是我到目前为止所尝试的.
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
development.log
在2014-07-16 10:48:07 0530开始获取127.0.0.1的“/ contacts / 3”
通过ContactsController处理#显示为HTML
参数:{“id”=>“3”}
[1m [36mContact Load(0.2ms)[0m [1mSELECT contacts.* FROM contacts WHERE contacts.id = 3 LIMIT 1 [0m]
呈现customer_support / customer_support.html.erb(0.1ms)
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)