Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 3 mandrill从本地主机发送电子邮件_Ruby On Rails 3_Email_Heroku_Mandrill - Fatal编程技术网

Ruby on rails 3 mandrill从本地主机发送电子邮件

Ruby on rails 3 mandrill从本地主机发送电子邮件,ruby-on-rails-3,email,heroku,mandrill,Ruby On Rails 3,Email,Heroku,Mandrill,我正在使用Mandrill为网站上的用户创建反馈表单(他们填写表单并向我发送电子邮件) 我想在开发中测试电子邮件功能。我使用unicorn作为服务器,我的本地地址是0.0.0:8080 但是,我收到一个500服务器错误,Net::SMTPServerBusy:中继访问被拒绝 我一步一步地按照赫罗库的指示去做 下面是m application.rb配置: config.action_mailer.smtp_settings = { :address => 'smtp.mandri

我正在使用Mandrill为网站上的用户创建反馈表单(他们填写表单并向我发送电子邮件)

我想在开发中测试电子邮件功能。我使用unicorn作为服务器,我的本地地址是0.0.0:8080

但是,我收到一个500服务器错误,Net::SMTPServerBusy:中继访问被拒绝

我一步一步地按照赫罗库的指示去做

下面是m application.rb配置:

config.action_mailer.smtp_settings = {
      :address => 'smtp.mandrillapp.com',
      :port => '587',
      :domain => 'heroku.com',
      :user_name => ENV['MANDRILL_USERNAME'],
      :password => ENV['MANDRILL_APIKEY']
    }

    ActionMailer::Base.delivery_method = :smtp
我按照mandrill/heroku网页上的说明进行设置

我用MANDRILL\u用户名和MANDRILL\u APIKEY设置了一个.env文件

这是我的ActionMailer文件:

class FeedbackMailer < ActionMailer::Base
  default :from => ""
  default :to => "xxx@stanford.edu"
  default :subject => "feedback about xxx"

  def send_feedback(message)
    #debugger
    @message = message
    mail(:from => message[:sender_email])

  end
end
class FeedbackMailer“”
默认值:to=>”xxx@stanford.edu"
默认值:主题=>“关于xxx的反馈”
def发送反馈(信息)
#调试器
@消息=消息
邮件(:发件人=>邮件[:发件人\电子邮件])
结束
结束
任何帮助都将不胜感激


我可以确认在生产环境中发送电子邮件。

如果您的所有设置都在生产环境中工作,但不是在本地工作,则有几种可能性:

  • 如何将变量从.env加载到env?环境变量可能没有按预期在本地加载。如果您在本地硬编码凭据,它能工作吗

  • 您可能遇到端口或出站SMTP通信被阻止的问题。考虑尝试端口2525,因为它不太可能被本地ISP阻塞。即使您的ISP正在阻止其他SMTP通信,启用SSL的端口465也可以工作


  • 您是否在应用程序.rb中尝试了config.action\u mailer.delivery\u method=:smtp而不是ActionMailer::Base.delivery\u method=:smtp?您的第一个答案是正确的-在生产中工作,但在开发中没有。