Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/56.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/312.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 ArgumentError(发送邮件需要SMTP收件人地址-Rails 4_Ruby On Rails_Checkbox_Mailer_Mailgun - Fatal编程技术网

Ruby on rails ArgumentError(发送邮件需要SMTP收件人地址-Rails 4

Ruby on rails ArgumentError(发送邮件需要SMTP收件人地址-Rails 4,ruby-on-rails,checkbox,mailer,mailgun,Ruby On Rails,Checkbox,Mailer,Mailgun,我正在尝试根据复选框选择从我的应用程序请求控制器发送电子邮件。它仅在开发环境中有效,但当我尝试在生产环境中执行此操作时,我收到以下消息: ArgumentError (An SMTP To address is required to send a message. Set the message smtp_envelope_to, to, cc, or bcc address.) 这是我的配置/环境/产品,看起来像: ActionMailer::Base.smtp_settings = {

我正在尝试根据复选框选择从我的应用程序请求控制器发送电子邮件。它仅在开发环境中有效,但当我尝试在生产环境中执行此操作时,我收到以下消息:

ArgumentError (An SMTP To address is required to send a message. Set the message  smtp_envelope_to, to, cc, or bcc address.)
这是我的配置/环境/产品,看起来像:

ActionMailer::Base.smtp_settings = {
    :port           => ENV['MAILGUN_SMTP_PORT'],
    :address        => ENV['MAILGUN_SMTP_SERVER'],
    :user_name      => ENV['MAILGUN_SMTP_LOGIN'],
    :password       => ENV['MAILGUN_SMTP_PASSWORD'],
    :domain         => 'https://paperthincut.herokuapp.com',
    :authentication => :plain,
  }
  ActionMailer::Base.delivery_method = :smtp
  config.action_mailer.default_url_options = { host: 'https://paperthincut.herokuapp.com' }
end
这是我能想到的唯一不同于开发环境的部分。有人有什么建议吗

更新:

  def create
    @request = Request.new(request_params)
    @request.add_items_from_basket(@basket)

      if @request.save
        Basket.destroy(session[:basket_id])
        session[:basket_id] = nil
        AppMailer.request_deliver(@request).deliver
        redirect_to distributors_path
      else
        render :new
      end
  end
我的app.mailer:

class AppMailer < ActionMailer::Base
  def request_deliver(request)
    @request = request
    mail smtp_envelope_to: @request.email, from: "marvkiluw@gmail.com", subject: "Order   from Marvin - In The Raw Broken Arrow"
  end
end
我的收藏复选框:

<%= f.collection_check_boxes :distributor_ids, Distributor.all, :id, :name do |cb|%>
  <% cb.label(class: "checkbox inline") {cb.check_box(class: "checkbox") + cb.text} %>
<% end %>

看看你在哪里给邮递员打电话,把电话写在if语句中

我希望这对你有用


继续编码

你能告诉我们你实际发送邮件的行吗?我刚刚更新了我的问题,你的应用程序看起来像什么?对不起,我第一次在stackoverflow问问题。我刚刚又更新了一次。提前谢谢你只需使用到:而不是smtp信封到:我如何确定[:你的复选框]是分发服务器ID吗?我刚刚更新了我的问题“如果参数[:分发服务器ID]”是否需要循环抛出它们。参数的值是多少
if params[:your_check_box]
  call_to_mailer
end