I'm trying to send an email to administrator from the production environment, but failing to... It works in development with letter opener gem, but when I try in production, I'm getting the following error:
Net::SMTPAuthenticationError (530-5.5.1 Authentication Required. Learn more at app/controllers/contact_us_controller.rb:8:in `submit_form'
app/models/contact_form.rb:13:in `send_admin_notification'
My code for the submit_form action in the controller is:
def submit_form
#contact_form.attributes = contact_form_params
return redirect_to action: :thanks if #contact_form.save
render :index
end
and the code in the contact_form model is:
def send_admin_notification
AdminNotifier.contact_form(self).deliver_now
end
I've been struggling with this for the past 2 days so any help and guidance would much much appreciated
This works well for me on the production env:
config.action_mailer.smtp_settings = {
:address => 'smtp.gmail.com',
:port => 587,
:domain => 'gmail.com',
:user_name => 'koshlendra#gmail.com',
:password => 'secret_password',
:authentication => 'login',
:enable_starttls_auto => true
}
Try putting these configurations in your production.rb file
config.action_mailer.delivery_method = :smtp
config.action_mailer.default_url_options = { host:'yourhost'}
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default :charset => "utf-8"
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => 'gmail.com',
:user_name => "your email",
:password => "yourpassword",
:authentication => :plain,
:enable_starttls_auto => true
}
Related
I am trying to send mails with SendGrid from my Rails app (using Hartl's tutorial). It didn't work by simply using the addon at Heroku because it needed my credit card. Then I signed up on SendGrid and used my credentials as above, but still no mail. Here above is my production.rb file. Some help, please?
config.action_mailer.delivery_method = :smtp
host = '<https://nameless-sierra-13544>.herokuapp.com'
config.action_mailer.default_url_options = { host: host }
ActionMailer::Base.smtp_settings = {
:address => 'smtp.sendgrid.net',
:port => '587',
:authentication => :plain,
:user_name => ENV['myusername'],
:password => ENV['mypass#'],
:domain => 'heroku.com',
:enable_starttls_auto => true
}
Merci,
In line with the comment above, I believe your values are just a little off. I also believe you need to have a from address set. This is a copy of what I use in production, with your values put in, and it works so hopefully this helps. I do believe that missing a valid from address and the characters in your domain value are why this is not working. Of course, also make sure you have the ENV variables set on heroku.
production.rb
config.action_mailer.delivery_method = :smtp
config.action_mailer.default_url_options = { host:'https://nameless-sierra-13544.herokuapp.com' }
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default :charset => "utf-8"
ActionMailer::Base.smtp_settings = {
:from => 'your_email_here#email.com',
:user_name => ENV['myusername'],
:password => ENV['mypass#'],
:domain => 'https://nameless-sierra-13544.herokuapp.com',
:address => 'smtp.sendgrid.net',
:port => 587,
:authentication => :plain,
:enable_starttls_auto => true
}
Net::SMTPAuthenticationError in Devise::ConfirmationsController#create
530-5.5.1 Authentication Required. Learn more at
I am using the gem 'devise'.
to send confirmation email with gmail account.
but, the error in title occur.
I searched many cases similar to my case and tried solutions in there, but those perfectly not worked, so I think my error has some different origin
( what I tried is : 1. less securing myaccount.google.com/u/1/security 2. http://www.google.com/accounts/DisplayUnlockCaptcha)
development.rb
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.smtp_settings = {
:authentication => :plain,
:address => "smtp.gmail.com",
:port => 587,
:domain => "mail.google.com",
:user_name => ENV["******#gmail.com"],
:password => ENV["******"],
:enable_starttls_auto => true
}
config.action_mailer.default_url_options = {:host => 'localhost:3000'}
top most error line in error page
def check_response(res)
unless res.success?
raise res.exception_class, res.message
end
end
please help me... TT
the problem your gmail setting, you should remove the ENV as you put string directly to it (as my understanding this is your local development this will generate an error since you also put config.action_mailer.raise_delivery_errors = true
config.action_mailer.smtp_settings = {
:authentication => :plain,
:address => "smtp.gmail.com",
:port => 587,
:domain => "mail.google.com",
:user_name => "******#gmail.com",
:password => "******",
:enable_starttls_auto => true
}
I am migrating an ROR3 application to ROR4. And I am very new to this and I am learning along with the migration.
I got stuck in the first step it self
I am getting an error
Net::SMTPAuthenticationError in ClientsController#create
534-5.7.14 <https://accounts.google.com/ContinueSignIn?sarp=1&scc=1&plt=AKgnsbtq6
Here is my configuration in development.rb.
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "gmail.com",
:user_name => Rails.application.secrets.email_address,
:password => Rails.application.secrets.email_password,
:authentication => "plain",
:enable_starttls_auto => true }
The place where I am getting the error is at
#client.save.
Apartment::Tenant.create(#client.subdomain)
Apartment::Tenant.switch(#client.subdomain)
#client.save
redirect_to new_user_session_url(subdomain: #client.subdomain)
else
render action: 'new'
Can anyone help who is working on ROR?
I had this same issue, be sure to take a look at your gmail account security settings and enable "Access for less secure apps" from www.google.com/settings/security."
Try this
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:user_name => "your mail",
:password => "your password",
:authentication => :plain,
:enable_starttls_auto => true
}
I'm having problems with an error when trying to send mails with my App with Mandrill.
I've seen a lot of people have this problem, and I'm sure it has to do with my mailer configuration. See if someone knows how to deal with this, because I'm desperate about it.
ERROR:
Errno::ECONNREFUSED (Connection refused - connect(2)):
production.rb
# Config default action mailer
config.action_mailer.default_url_options = { :host => "localhost" }
config.action_mailer.smtp_settings = {
:address => "smtp.mandrillapp.com",
:port => 587,
:enable_starttls_auto => true,
:user_name => ENV["MANDRILL_USERNAME"],
:password => ENV["MANDRILL_PASSWORD"],
:authentication => 'login',
:domain => 'heroku.com'
}
# Setup for production - deliveries, no errors raised
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.default :charset => "utf-8"
We use Mandrill in production like this:
#config/environments/production.rb
config.action_mailer.smtp_settings = {
:address => "smtp.mandrillapp.com",
:port => "587",
:authentication => :plain,
:user_name => "username",
:password => "API key",
:enable_starttls_auto => true
}
We literally have no other options for Heroku - I think you should remove the default_url_options and domain options
I am using Rails 3 and implementing the email sending feature. I am not sure if my configuration is correct, but here are my codes:
mailers/user_mailer.rb
class UserMailer < ActionMailer::Base
default :from => "user#gmail.com"
def send_to(user)
#user = user
subject='welcome !'
mail(:to=>'y.lan#gmail.com', :subject=>subject, :content_type => "text/html")
mail.deliver
end
end
controller:
def CarsController < BaseController
...
def register_finish
UserMailer.send_to(user)
end
end
config/enviroment.rb
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.googlemail.com",
:port => 532,
:arguments => '-i'
:enable_starttls_auto => true
}
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
When my controller invoke 'register_finish' function and try to send email to a user, I always get Timeout::Error (execution expired) error message, what could be the reason??
I saw some people define the configuration in config/initializers/setup_email.rb and use
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = { ...}
while I configure it in config/enviroment.rb and use:
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {...}
I also saw some people invoke "deliver" method inside controller while I invoke it inside 'UserMailer'.
My questions:
What's the difference between my implementation and the above different way of implementations I found from internet.
Why I got timeout errors?
I'm also using gmail as my smtp server and I've adder setup_email.rb to initiliazers containing this code
ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "domain.pl",
:user_name => "username",
:password => "password",
:authentication => "plain",
:enable_starttls_auto => true
}
and it works for me :)
EDIT
I've just notice we are using different servers, maybe try with my config?
Timeout errors mean that there is some authentication errors.
This line is no longer needed:
ActionMailer::Base.delivery_method = :smtp
While it is adviceable to set the smtp_settings in an initializer.
If you are using it on a development machine this configuration should work with gmail:
ActionMailer::Base.smtp_settings = {
:enable_starttls_auto => true,
:address => 'smtp.gmail.com',
:port => 587,
:domain => 'your_domain',
:authentication => :plain,
:user_name => 'your_gmail_username',
:password => 'your_gmail_password'
}
EDIT
you can add for a development machine:
ActionMailer::Base.default_url_options[:host] = "localhost:3000"
Very good railscast on subject
Have a look at this:
http://lindsaar.net/2010/3/15/how_to_use_mail_and_actionmailer_3_with_gmail_smtp
Works nicely for me