rails email error - 530-5.5.1 Authentication Required. - ruby-on-rails

trying to send email form Ruby on Rails but getting this:
SocketError in UsersController#create
getaddrinfo: nodename nor servname provided, or not known
My environments/development.rb file has:
config.action_mailer.smtp_settings = {
address: "smtp.gmail.com",
port: 587,
domain: "my_company.org",
authentication: "plain",
enable_starttls_auto: true,
user_name: "my_username#my_company.org",
password: "my_pass"
}
and
config.action_mailer.delivery_method = :smtp
and
config.action_mailer.default_url_options = { :host => 'localhost:5000' }
# 5000 rather than 3000 as I am using foreman.

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'
}
and please note the
:openssl_verify_mode => 'none'
section to skip the SSL errors.
But sorry, I have no idea what the error is, probably you try to use the Gmail SMTP server with another domain name.

In case others face the same issue, I just wanted to add that I had the exact same problem trying to implement a mailing system with gmail in my Rails API, and adding :openssl_verify_mode => 'none' did not solve the problem for me.
Instead, installing the figaro gem and then adding my environment variable in application.yml like so:
gmail_username: "myemail#gmail.com"
gmail_password: "mypassword"
did the trick for me.
(and dont forget to change you SMTP settings: )
user_name: ENV['gmail_username'],
password: ENV['gmail_password'],

Related

Not able to deliver the mail in canvas lms? What configuration setting i am missing?

This is my outgoing_mail.yml files
If click on the forgot password link It is showing in the delayed_job.log
My email is deliver got stuck please help me.
production:
address: "smtp.gmail.com"
port: "587"
user_name: "xxxxxx#gmail.com"
password: "password"
authentication: "plain" # plain, login, or cram_md5
domain: "domain_name.com"
outgoing_address: "xxxxxx#gmail.com"
default_name: "Instructure Canvas"
My SMTP settings are right but the in site admin settings there is feature option section there is an option "Use remote service for notifications" is No so is if you use remote service like mailer etc. this option turns into off.
And It's working fine.
In config/environments/production.rb
config.action_mailer.delivery_method = :smtp
config.action_mailer.default_url_options = { host:'your host', port: 'xxx' }
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 => 'abc.com',
:user_name => "xxxx#mail.com",
:password => "xxxx",
:authentication => :plain,
:enable_starttls_auto => true
}

Action Mailer production.rb not working when deployed via Sendgrid and Heroku

I'm currently in the process of trying to send Account Confirmation emails to any new user that creates an account on my Rails app.
I've successfully deployed locally via development.rb, but for some reason I get an error message every time "We're sorry, but something went wrong. If you are the application owner check the logs for more information". I've reviewed several resources both here on Stack Overflow as well as Heroku, Youtube and have not been able to find a solution.
Here is my code in environments/production.rb:
# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_deliveries = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: "smtp.sendgrid.net",
port: 587,
domain: ENV["SENDGRID_DOMAIN"],
authentication: "plain",
enable_starttls_auto: true,
user_name: ENV["SENDGRID_USERNAME"],
password: ENV["SENDGRID_PASSWORD"]
}
config.action_mailer.default_url_options = {:host => "<myherokuappname>.herokuapp.com/"}
config.action_mailer.perform_caching = false
Again just to confirm, I am able to deploy emails locally, just not at the production level. Any tips would be greatly appreciated.
I recently integrated SendGrid into my Heroku app too. My production.rb settings are as follows:
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default_url_options = { host: '<myherokuappname>.herokuapp.com' }
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:user_name => ENV['SENDGRID_USERNAME'],
:password => ENV['SENDGRID_PASSWORD'],
:domain => '<myherokuappname>.herokuapp.com',
:address => 'smtp.sendgrid.net',
:port => 587,
:authentication => :plain,
:enable_starttls_auto => true
}
I tested this out just a few minutes ago and it sends fine.

Rails Gmail contact form - works on localhost but not when deployed to Heroku

I am having a strange problem, I am coding a GMAIL contact form - which will use an existing Gmail username and password to send emails to a pre-specified Gmail account.
The issue I am having is that when I run everything locally it works just fine. Once I deploy to Heroku on the other hand ... I am not receiving the messages. When I run: heroku logs -t it seems to show that the message has been sent but nothing is still coming through.
Configuration:
ActionMailer::Base.default_url_options = { :host => 'domain.herokuapp.com' }
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.raise_delivery_errors = true
ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:enable_starttls_auto => true,
:domain => 'domain.herokuapp.com',
:user_name => ENV['GMAIL_USERNAME'],
:password => ENV['GMAIL_PASSWORD'],
:authentication => "login"
}
Note:
domain.herokuapp.com has just been subbed in for my actual domain.
Screen shot of server logs:
Does anyone have any idea of why this is not working or can point me to a resource to get this resolved?
I had a similar problem, it was connected to the configuration in config/enfironments/production.rb file i had
config.action_mailer.default_url_options = { host: 'http://barteringapps.herokuapp.com' }
I was able to solve this problem by changing the address. In development it should be http://127.0.0.1:3000, while it should be your domain in production.
Also your gmail domain is not correct, you should have gmail.com as domain
config.action_mailer.smtp_settings = {
address: "smtp.gmail.com",
port: 587,
domain: ENV["GMAIL_DOMAIN"],
authentication: "plain",
user_name: ENV["GMAIL_USERNAME"],
password: ENV["GMAIL_PASSWORD"],
enable_starttls_auto: true
}
I followed this post, but be careful when configuring the default_url_options as it would give me problems with facebook omniauth
https://rubyonrailshelp.wordpress.com/2014/01/02/setting-up-mailer-using-devise-for-forgot-password/

Net::SMTPAuthenticationError in UsersController#create

our Rails 3.2 application's "resend activation code" mail feature was working until the code was transferred from the previous developer to us. Now we get this error
Net::SMTPAuthenticationError in UsersController#create
Our mail settings remain untouched like this:
ActionMailer::Base.smtp_settings = {
:address => "smtp.sendgrid.net",
:port => 587,
:domain => "example.com",
:user_name => "username",
:password => "password",
:authentication => "plain",
:enable_starttls_auto => true
}
We are somehow not able to figure it out as to why the email stop's working.
We have checked the gmail server also responding back to us via telnet.
We have also enabled the Less Secure Apps feature of Gmail's in Security -> Account permissions -> Access for less secure apps
Thanks in advance.
You mentioned using Gmail's settings, I'd say you should try this:
ActionMailer::Base.smtp_settings = {
address: "smtp.gmail.com",
port: 587,
user_name: ENV['GMAIL_USERNAME'],
password: ENV['GMAIL_PASSWORD'],
authentication: :plain,
enable_starttls_auto: true
}
If you're using Sendgrid, as above you should have something like:
ActionMailer::Base.smtp_settings = {
user_name: ENV['SENDGRID_USERNAME'],
password: ENV['SENDGRID_PASSWORD'],
domain: 'heroku.com', #for your helo domain
address: 'smtp.sendgrid.net',
port: 587,
authentication: :plain,
enable_starttls_auto: true
}
Don't forget to define your ENV variables appropriately.
You can find more discussion around this here

How to send emails in development environment using gmail SMTP and devise?

I am trying to send emails while being on localhost and using devise (I need emails for user registration and password reset)
I have put this in my environment.rb file
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: "smtp.gmail.com",
port: 587,
domain: "gmail.com",
authentication: "plain",
enable_starttls_auto: true,
user_name: ENV["username"],
password: ENV["password"]
}
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
but I am not getting any mails and not seeing any error too (devise says ).
What am I missing ?
Where can I see the log for emails (success or
failure) ?
EDIT - OK, it worked after adding this line
:openssl_verify_mode => 'none'
Check this too rails email error - 530-5.5.1 Authentication Required.

Resources