11 Nov 2013, 22:35
Generic-user-small

david phoon (1 post)

I spent almost a week trying to debug this after reading many discussion groups. After checkout and hitting button Place Order I get “We’re sorry, but something went wrong.” with message from the rails server log Errno::ECONNREFUSED (No connection could be made because the target machine actively refused it. - connect(2)): app/controllers/orders_controller.rb:41:in block in create' app/controllers/orders_controller.rb:35:in create’

orders_controller snap shot of create is : ~~~ (Line 35)def create @order = Order.new(order_params) @order.add_line_items_from_cart(current_cart)

respond_to do |format|
  if @order.save
	Cart.destroy(session[:cart_id])
	session[:cart_id] = nil
	#Notifier.gmail_message.deliver
	#Notifier.order_received(@order).deliver
        (Line41)Notifier.order_shipped(@order).deliver
	format.html { redirect_to(store_url, :notice => 'Thank you for your order.' ) }
	format.xml { render :xml => @order, :status => :created,:location => @order }
  else
    format.html { render action: 'new' }
    format.json { render json: @order.errors, status: :unprocessable_entity }
  end
end   end

debugging found the failure of the calling Line 41 to
order_notifier.rb mail to:.....

def shipped(order) @order = order

mail to: order.email, subject: 'Pragmatic Store Order Shipped' ~~~

In production.rb, I have included: ~~~config.action_mailer.delivery_method = :smtp config.action_mailer.smtp_settings = { :tls => true, :enable_starttls_auto => true, :address => “smtp.gmail.com”, :port => “587”, :domain => “domain.com”, :authentication => :plain, # :user_name => “mygmailaccount@gmail.com”, # :password => “mygmailpassword” } One discussion was about using telnet to see if there is conflict of ports- to change ports etc.

Also I was able to run and send email using ruby using 587 though I note it is not using the rails server: ~~~ require ‘tlsmail’ require ‘time’

content = «EOF From: mygmailaccount@gmail.com To: mygmailaccount@gmail.com Subject: Hello! Date: #{Time.now.rfc2822}

How are you. EOF

Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE) Net::SMTP.start(‘smtp.gmail.com’, 587, ‘gmail.com’, ‘mygmailaccount@gmail.com’, ‘mypassword’, :login) do |smtp| smtp.send_message(content, ‘mygmailaccount@gmail.com’, ‘mygmailaccount@gmail.com’) end

~~~ any futher pointers getting desperate for answers to send the email.

  You must be logged in to comment