2014-11-19 5 views
1

확인란을 선택하여 응용 프로그램 요청 컨트롤러에서 전자 메일을 보내려고합니다.이 옵션은 개발 환경에서 찾으면 작동하지만 시도 할 때 작동합니다. 이처럼 내 설정/환경/생산 보이는입니다ArgumentError (SMTP를 사용하려면 메일을 보내려면 주소가 필요합니다. - Rails 4

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: "[email protected]", subject: "Order from Marvin - In The Raw Broken Arrow" 
    end 
end 

내 컬렉션의 check_boxes : 당신이 우편물로 전화를 걸 곳에서

<%= 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 %> 
+0

u가 실제로 메일을 보내는 라인을 보여줄 수 있습니까? – marvwhere

+0

방금 ​​ –

+0

님의 질문을 업데이트했으며 AppMailer가 어떻게 생겼습니까? – marvwhere

답변

0

찾는 위치에서 그 전화를 포장 a if 문

if params[:your_check_box] 
    call_to_mailer 
end 

이 정보가 도움이 되었기를 바랍니다.

코딩을 계속 하시겠습니까?

+0

[: your_check_box]는 어떻게 결정합니까? distributor_ids가 맞습니까? 방금 질문을 업데이트했습니다. –

+0

'params [: distributor_ids]'가 루프를 던져야 할 경우. 'params'의 값은 무엇입니까? –