1
votes

So i've look at a few similar posts here on SO, but for some reason my sendgrid config in heroku is not working.

Here's my config / production.rb

config.action_mailer.default_url_options = { :host => 'poliking.herokuapp.com' }  
config.action_mailer.delivery_method = :smtp

config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = false
ActionMailer::Base.smtp_settings = {
:from => '[email protected]',
:user_name => ENV['SENDGRID_USERNAME'],
:password => ENV['SENDGRID_PASSWORD'],
:domain => 'poliking.herokuapp.com',
:address => 'smtp.sendgrid.net',
:port => 587,
:authentication => :plain,
:enable_starttls_auto => true
}

Everything worked perfectly fine in development. I tried all the obvious, YES variables are properly set and YES I enabled my gmail to allow mail from less secure apps.

added gem sendgrid gem to my gem file

gemfile.rb

gem 'sendgrid-ruby'

Again, everything working fine in development and I am receiving email to same email address. But this isn't working in production. Any thoughts?

Here's the log:

...MailForm::Notifier#contact: processed outbound mail in 3.3ms...
Delivered mail 5f246d3cbf2d9_42af68b690f1c810d6@dad81cb4-1ce9-440e-b8...
1
Maybe setting config.action_mailer.raise_delivery_errors = true might help identifying the problem. What happens if you run your application in production environment in your computer? - cesartalves
For some reason when I make that option = true, the email doesn't even do its front end confirmation and I get: Net::SMTPAuthenticationError: 535 Authentication failed: account disabled (Most recent call first) - Wes Creations
I tried Mailgun and had much better luck. Removed sendgrid addon, added mailgun, added mailgun-ruby to gem file, ran bundle install, and used this code and it works like a charm: config.action_mailer.perform_deliveries = true config.action_mailer.raise_delivery_errors = false ActionMailer::Base.smtp_settings = { :user_name => ENV['MAILGUN_SMTP_LOGIN'], :password => ENV['MAILGUN_SMTP_PASSWORD'], :domain => ENV['MAILGUN_DOMAIN'], :address => ENV['MAILGUN_SMTP_SERVER'], :port => ENV['MAILGUN_SMTP_PORT'], :authentication => :plain, :enable_starttls_auto => true } - Wes Creations

1 Answers

0
votes

With config.action_mailer.raise_delivery_errors = false, the errors raised during e-mail delivery will be suppressed.

Therefore, change that option to true so that you can diagnose the problem.