Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/53.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 在生产环境中发送邮件_Ruby On Rails_Gmail_Actionmailer_Production Environment - Fatal编程技术网

Ruby on rails 在生产环境中发送邮件

Ruby on rails 在生产环境中发送邮件,ruby-on-rails,gmail,actionmailer,production-environment,Ruby On Rails,Gmail,Actionmailer,Production Environment,我正在尝试在生产环境中发送邮件,如下所示: 在user-mailer.rb中: class UserMailer < ActionMailer::Base default to: "a.b@gmail.com" def feedBack_mail(email,message) @mess=message @url = 'http://www.google.com' mail(from: email, subject: 'new_feedback') e

我正在尝试在生产环境中发送邮件,如下所示:

在user-mailer.rb中:

class UserMailer < ActionMailer::Base
  default to: "a.b@gmail.com"
  def feedBack_mail(email,message)
    @mess=message
    @url  = 'http://www.google.com'
    mail(from: email, subject: 'new_feedback')
  end
end
在production.rb中,我添加了以下配置:

if config.respond_to?(:action_mailer)
    # config.action_mailer.raise_delivery_errors = false
    config.action_mailer.default_url_options = { :host => 'monsite.com' }
    # ActionMailer Config
    # Setup for production - deliveries, no errors raised
    config.action_mailer.delivery_method = :smtp
    config.action_mailer.perform_deliveries = true
    config.action_mailer.raise_delivery_errors = false
    config.action_mailer.default :charset => "utf-8"
    config.action_mailer.smtp_settings = {
        address: "smtp.gmail.com",
        port: 25,
        domain: "monsite.com",
        authentication: "plain",
        enable_starttls_auto: true,
        user_name: ENV["GMAIL_USERNAME"],
        password: ENV["GMAIL_PASSWORD"]
    }
  end
我在production.log中得到了什么

I, [2015-02-17T15:38:05.436159 #2003552]  INFO -- : Started POST "/feedback/send.json" for 197.14.10.26 at 2015-02-17 15:38:05 +0100
I, [2015-02-17T15:38:05.473826 #2003552]  INFO -- : Processing by UsersController#create as JSON
I, [2015-02-17T15:38:05.473943 #2003552]  INFO -- :   Parameters: {"email"=>"c.d@gmail.com", "message"=>"qerfsertq", "user"=>{"email"=>"c.d@gmail.com", "message"=>"qerfsertq"}}
I, [2015-02-17T15:38:05.524701 #2003552]  INFO -- :   Rendered user_mailer/feedBack_mail.text.erb (0.5ms)
I, [2015-02-17T15:38:08.673302 #2003552]  INFO -- : 
Sent mail to a.b@gmail.com (755.5ms)
I, [2015-02-17T15:38:08.674260 #2003552]  INFO -- : Completed 201 Created in 3200ms (Views: 0.3ms | ActiveRecord: 0.0ms)
但是我没有收到任何发到a的邮件。b@gmail.com连垃圾邮件都没有


我真的不明白问题出在哪里

我通过创建一个
Mandrill
帐户并更改如下配置来解决问题:

config.action_mailer.smtp_settings = {
        :port =>           '587',
        :address =>        'smtp.mandrillapp.com',
        :user_name =>      'xxxxxxxx',
        :password =>       'xxxxxx',
        :domain =>         'domain.com',
        :authentication => :plain
    }
    config.action_mailer.perform_deliveries = true
    config.action_mailer.raise_delivery_errors = true
    config.action_mailer.default_url_options = { host: "monsite.com" }

尝试smtp配置中的端口587谢谢您的响应,但仍然存在相同的问题:/
I, [2015-02-17T15:38:05.436159 #2003552]  INFO -- : Started POST "/feedback/send.json" for 197.14.10.26 at 2015-02-17 15:38:05 +0100
I, [2015-02-17T15:38:05.473826 #2003552]  INFO -- : Processing by UsersController#create as JSON
I, [2015-02-17T15:38:05.473943 #2003552]  INFO -- :   Parameters: {"email"=>"c.d@gmail.com", "message"=>"qerfsertq", "user"=>{"email"=>"c.d@gmail.com", "message"=>"qerfsertq"}}
I, [2015-02-17T15:38:05.524701 #2003552]  INFO -- :   Rendered user_mailer/feedBack_mail.text.erb (0.5ms)
I, [2015-02-17T15:38:08.673302 #2003552]  INFO -- : 
Sent mail to a.b@gmail.com (755.5ms)
I, [2015-02-17T15:38:08.674260 #2003552]  INFO -- : Completed 201 Created in 3200ms (Views: 0.3ms | ActiveRecord: 0.0ms)
config.action_mailer.smtp_settings = {
        :port =>           '587',
        :address =>        'smtp.mandrillapp.com',
        :user_name =>      'xxxxxxxx',
        :password =>       'xxxxxx',
        :domain =>         'domain.com',
        :authentication => :plain
    }
    config.action_mailer.perform_deliveries = true
    config.action_mailer.raise_delivery_errors = true
    config.action_mailer.default_url_options = { host: "monsite.com" }