Reputation:
In order_mailer.rb
:
default from: '[email protected]'
def welcome_email(order)
@user = "Uday kumar das"
@url = 'http://example.com/login'
mail(to: '[email protected]', subject: 'Welcome to My Awesome Site')
end
In orders_conroller
:
def delivery
@order1 = Order.where(:orderId=>params[:orderId])
@order = Order.find(@order1)
OrderMailer.welcome_email(@order).deliver
end
In environments/development.rb
:
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
I am new to mails in rails.I am referring http://guides.rubyonrails.org/action_mailer_basics.html to learn. I am getting error like:
Net::SMTPAuthenticationError in OrdersController#delivery`
530-5.5.1 Authentication Required. Learn more at`
Upvotes: 0
Views: 2711
Reputation:
I did the same using my gmail, following are my configurations, try and see it if works
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:authentication => :plain,
:user_name => "<my gmail>@gmail.com",
:password => "<my gmail password>",
:openssl_verify_mode => 'none' }
Please note the:
:openssl_verify_mode => 'none'
section to skip the ssl errors
Upvotes: 1