I have an application for rails 4. I created ActionMailer and I can send order confirmation emails through localhost and gmail.
I installed Sendgrid on Heroku and followed the setup instructions. I get Net::SMTPSyntaxError (501 Syntax error
my environment.rb (I have sendgrid user / pwd in application.yml)
ActionMailer::Base.smtp_settings = { :address => 'smtp.sendgrid.net', :port => '587', :authentication => :plain, :user_name => ENV['SENDGRID_USERNAME'], :password => ENV['SENDGRID_PASSWORD'], :domain => 'heroku.com', :enable_starttls_auto => true }
in production.rb is the only actionamailer parameter that I have. I have this as a placeholder to post a real domain later. I am currently using herokuapp.com.
config.action_mailer.default_url_options = { host: 'localhost:3000' }
in my order_controller in the order creation method, I call below.
AutoNotifier.orderconf_email(current_user, @order).deliver
auto_notifier.rb
class AutoNotifier < ActionMailer::Base default from: "Test Email" def orderconf_email(current_user, order) @buyer = current_user @order = order mail(to: @buyer.email, subject: 'Thank you for your order.') end end
What am I missing? It works on localhost with gmail, so I'm missing something in the sendgrid settings or in the default_url file in the production.rb file.
Moosa source share