微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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帐户中打开了两步验证,我用它来认:来自.所以我禁用了它,我的应用程序正常运行.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐