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”
通过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)

解决方法

我尝试使用以下代码引发运行时错误.

添加了这些行
development.rb文件.

config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true

我犯了一个非常愚蠢的错误.我在我的gmail帐户中打开了两步验证,我用它来认:来自.所以我禁用了它,我的应用程序正常运行.

相关文章

validates:conclusion,:presence=>true,:inclusion=>{...
一、redis集群搭建redis3.0以前,提供了Sentinel工具来监控各...
分享一下我老师大神的人工智能教程。零基础!通俗易懂!风趣...
上一篇博文 ruby传参之引用类型 里边定义了一个方法名 mo...
一编程与编程语言 什么是编程语言? 能够被计算机所识别的表...
Ruby类和对象Ruby是一种完美的面向对象编程语言。面向对象编...