user4965201
user4965201

Reputation: 973

Heroku- running rails app not sending mail and not showing error

I have a Rails app and in that i have a form which sends the mail after submitting

the production settings are

production.rb

  config.eager_load = true
  config.action_mailer.perform_deliveries = true
  config.action_mailer.default_url_options = { :host => 'jobzgoform.herokuapp.com'}
  # Full error reports are disabled and caching is turned on.
  config.consider_all_requests_local       = false
  config.action_mailer.raise_delivery_errors = true
  config.action_controller.perform_caching = true
  config.action_mailer.delivery_method = :smtp
  # SMTP settings for gmail
  config.action_mailer.smtp_settings = {
      :address              => "smtp.gmail.com",
      :port                 => 587,
      :domain               => "gmail.com",
      :user_name            => 'mygmailid',
      :password             => 'mygmailpassword',
      :authentication       => "plain",
      :enable_starttls_auto => true
  }

form_mailer.rb

class FormMailer < ApplicationMailer
 def registration_mail(form)
  mail(to: form.email, subject: 'JobzGo Registration')
 end
end

forms_controller.rb

def create
  @form = Form.create(form_params)
    if @form.save
      FormMailer.registration_mail(@form).deliver
      redirect_to forms_path
    end
  end

running on heroku it shows error after submitting the form i am receiving the data in the database but then it generated error on the page and mail is not sent. and in the logs i get

2015-11-27T13:19:43.550779+00:00 heroku[router]: at=info method=POST path="/forms" host=jobzgoform.herokuapp.com request_id=9943fd5e-a5f9-40cf-8f85-b6fd4cee59f0 fwd="182.71.29.59" dyno=web.1 connect=1ms service=685ms status=500 bytes=1683
2015-11-27T13:19:43.852960+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=jobzgoform.herokuapp.com request_id=6b6d904b-7c0e-4cc1-8219-a6cc3bd77d31 fwd="182.71.29.59" dyno=web.1 connect=0ms service=1ms status=200 bytes=157

not able to debug as i am not getting any error

Please help!!

Upvotes: 1

Views: 70

Answers (1)

Dushyant
Dushyant

Reputation: 4960

Please add rails_12factor gem (It helps in debugging/better_error_visibility on Heroku) in your Gemfile for production.

See the Heroku logs. Probability is you would be able to figure out the solution by yourself.

Also you can run rails server -e production to run in production environment at your local.

Hope it helps!

Upvotes: 1

Related Questions