I have deployed my rails web app to heroku. Now I want send email to the user who signed up to my web app. I want to send email from my business email. Let say my business email is abc#business-email.in.
I am getting error when I checked by doing heroku logs.
86ms: SocketError (getaddrinfo: Name or service not known):
Here is my mails settings in config/production.rb
#Heroku mail configuration
config.action_mailer.raise_delivery_errors = true
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.smtp_settings = {
:address => "smtp.business-email.in",
:domain => 'myApp.herokuapp.com',
:port => 25,
:user_name => "abc#business-email.in",
:password => ENV['SMTP_PASSWORD'],
:authentication => :plain,
:enable_starttls_auto => true
}
Related
I use devise and this error occurs when devise try to send email to confirm user's email.
Follow below my development.rb which
development.rb
# Email
config.action_mailer.delivery_method = :smtp
config.action_mailer.default_url_options = { host: 'domain.com' }
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.asset_host = 'badoda.com'
config.action_mailer.smtp_settings = {
:address => 'outlook.office365.com',
:port => 587,
:user_name => 'it#domain.com',
:password => 'password',
:domain => 'domain.com',
:authentication => :login,
:enable_starttls_auto => true
}
It seems to be an issue with Office 365 SMTP relay configuration. Please follow the steps here to configure SMTP properly.
Does your MIME message specify the right Sender header?
My question is very similar to this one but the accepted answer has not solved my problem.
Here is what I have for my config file:
# Config for mailserver
config.active_support.deprecation = :notify
config.action_mailer.delivery_method = :smtp
# SMTP settings for Exchange server
config.action_mailer.smtp_settings = {
:address => 'outlook.<domain>',
:port => 25,
:authentication => :ntlm,
:user_name => '<userName>#<domain>',
:password => '<unencryptedPassword',
:domain => '<domain>',
:enable_starttls_auto => true
}
I have tried setting up a relay connector on the Exchange server to accept requests from the IP address of my application.
Also, my original problem was before I used NTLM and my config file looked like so but I got the same error:
# Config for mailserver
config.active_support.deprecation = :notify
config.action_mailer.delivery_method = :smtp
# SMTP settings for Exchange server
config.action_mailer.smtp_settings = {
:address => 'outlook.<domain>',
:port => 25,
:authentication => :login,
:user_name => '<userName>#<domain>',
:password => '<unencryptedPassword',
:domain => '<domain>',
:enable_starttls_auto => true
}
I have successfully been able to send email using Gmail's SMTP server so I don't think it's the Rails side, but the Exchange server not recognizing my application.
Turns out I was using the wrong authentication because the Exchange server doesn't require any sort of authentication (mainly so printers, faxes, etc. don't need to authenticate).
Here's the resulting settings I used:
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => 'outlook.<domain>',
:port => 25,
:authentication => :plain,
:enable_starttls_auto => true
}
I am using mailboxer gem in my Rails application.
Following are the 2 methods in my User model, which is messageable -
def name
return :email
end
def mailboxer_email(object)
#Check if an email should be sent for that object
#if true
# mail(:to => :email, :subject => "Your Login credential")
return :email
#if false
#return nil
end
And following are my smtp settings in my development.rb file -
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default :charset => "utf-8"
Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE)
config.action_mailer.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:authentication => :plain,
:domain => 'gmail.com',
:user_name => 'address#gmail.com',
:password => 'mypassword',
:authentication => 'plain',
:enable_starttls_auto => true
}
But on creating a message, i am getting the following error -
Completed 500 Internal Server Error in 22136ms
Net::SMTPFatalError (553-5.1.2 We weren't able to find the recipient domain. Please check for any
553-5.1.2 spelling errors, and make sure you didn't enter any spaces, periods,
553 5.1.2 or other punctuation after the recipient's email address. eg3sm14283691pac.1 - gsmtp
):
`app/controllers/conversations_controller.rb:12:in `create`'
I am sure I am sending the email to a proper email address. Also, when i put debugger in mailboxer_email method, the email I see is valid one.
Any idea where I am going wrong?
You are getting the error:- "We weren't able to find the recipient domain"
by setting up the domain => 'gmail.com'
You should specify the
:domain => 'your application name' ( :domain => 'foo.com' or 'http://localhost:3000' )
also setup
config.action_mailer.delivery_method = :smtp
you change according production, development environment.
I am trying to use the gem Active Admin to send emails to users that I sign up so that they can create a password.
This entails a process of inserting the following code on the config/environments/development.rb
#Added per active admin install instructions
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
#These settings are for the sending out email for active admin and consequently the devise mailer
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,
:domain => 'gmail.com', #you can also use google.com
:authentication => :plain,
:user_name => 'XXX#gmail.com',
:password => 'XXXX'
}
THis works no problems
For deploying to the production site on Heroku. I inserted the following code into the config/environments/production.rb
#Added per active admin install instructions
config.action_mailer.default_url_options = { :host => 'http://XXXX.herokuapp.com/' }
#These settings are for the sending out email for active admin and consequently the devise mailer
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,
:domain => 'gmail.com', #you can also use google.com
:authentication => :plain,
:user_name => 'XXX#gmail.com',
:password => 'XXX'
}
But now the emails donot get sent. Instead I see a "We're sorry soemthing went wrong" message in the browser and the logs say the following lines
2012-08-17T17:39:34+00:00 app[web.1]: cache: [GET /admin/admin_users/new] miss
2012-08-17T17:39:34+00:00 app[web.1]: Started POST "/admin/admin_users" for 96.49.201.234 at 2012-08-17 17:39:34 +0000
2012-08-17T17:39:35+00:00 app[web.1]: Net::SMTPAuthenticationError (535-5.7.1 Please log in with your web browser and then try again. Learn more at
2012-08-17T17:39:35+00:00 app[web.1]: ):
2012-08-17T17:39:35+00:00 app[web.1]: app/models/admin_user.rb:35:in `block in <class:AdminUser>'
2012-08-17T17:39:35+00:00 app[web.1]: cache: [POST /admin/admin_users] invalidate, pass
Where should I go from here? Can someone please give me a hand
Here is a useful help from Gmail: http://support.google.com/mail/bin/answer.py?hl=en&answer=14257&p=client_login.
The problem is Gmail prevents suspicious sign-in attempt that may be robot. We need to grant permission to the app so that it can use Google Account to send email.
Gmail requires SSL connections to their mail servers. Try adding this to your SMTP settings:
:enable_starttls_auto => true
Try following code:
ActionMailer::Base.smtp_settings =
{
:address => 'smtp.gmail.com',
:port => 587,
:domain => 'gmail.com', #you can also use google.com
:authentication => 'plain',
:user_name => 'XXX#gmail.com',
:password => 'XXX',
:enable_starttls_auto => true
}
Changes made:
1. :authentication => :action to :authentication => 'plain'
2. added :enable_starttls_auto => true , as commented by janders223 above.
http://www.google.com/accounts/DisplayUnlockCaptcha click on this and give access to it. The next time it will work
I created my mail contact formular with this post: link
In the post regards to gmail. I'm from Germany, I could only use googlemail.com instead. So I changed everything from gmail to googlemail. I get no errormessages but no mails are received in the googlemail account.
This is my mailing config:
# Mail config
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.googlemail.com",
:port => 587,
:user_name => 'khsuite#googlemail.com',
:password => 'mypassword',
:authentication => 'plain',
:enable_starttls_auto => true }
Are there any other settings necessary for googlemail?