I'm having an issue properly setting up my web application to use Windows Live Hosted email instead of the normal Google Apps Email. This is due to the fact that Google is down charging for such services.
I've entered in the proper config.action_mailer.smtp_settings, but for some reason I can't get email notifications to properly send. My config below, if I swap the config with another Google Apps config settings email, it's functional. Am I missing something?
config.action_mailer.smtp_settings = {
:enable_starttls_auto => true,
:address => "smtp.live.com",
:port => "587",
:domain => "mail.live.com",
:user_name => "###########.net",
:password => "###########",
:authentication => :plain
}
This is the error I am receiving.
getaddrinfo: nodename nor servname provided, or not known
here is my configuration:
config.action_mailer.smtp_settings = {
:address => "smtp.live.com",
:port => 587,
:domain => 'example.com',
:user_name => 'XXXXXXXXX',
:password => 'XXXXXXXXX',
:authentication => 'plain',
:enable_starttls_auto => true }
The only difference is the authentication.
Also remember this line
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
Related
I am trying to set up an action mailer, so people can send a message using contact form on my website.
Here is my configuration for production:
config.action_mailer.default_url_options = { host: 'mydomain.co' }
config.action_mailer.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:address => 'smtp.gmail.com',
:port => 587,
:authentication => :plain,
:user_name => ENV['GMAIL_USERNAME'],
:password => ENV['GMAIL_PASSWORD'],
:domain => 'mydomain.co',
:enable_starttls_auto => true
}
I was trying to test it and the mail is delivered, but after that I immidiately receive a message from "Mail Delivery Subsystem" with a subject "Delivery Status Notification (Failure)".
What is causing this message and how to avoid it?
Mine looks like this
config.action_mailer.smtp_settings = {
:address => 'smtp.gmail.com',
:port => 587,
:domain => 'gmail.com',
:user_name => ENV["GMAIL_USERNAME"],
:password => ENV["GMAIL_PASS"],
:authentication => 'plain',
:enable_starttls_auto => true
}
Also make sure you've enabled "Less Secure Apps" in your Gmail settings:
https://support.google.com/accounts/answer/6010255?hl=en
Hope that helps!
I am deploying an ruby-on-rails app in Heroku.I cannot add the SendGrid add-on to the heroku account.Is there any other ways to use the email services?
Yes you can simply sign up for a SendGrid account directly and then use the SMTP details. It would look like this:
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.sendgrid.net",
:port => 587,
:domain => 'yourdomain.com',
:user_name => ENV['SENDGRID_USERNAME'],
:password => ENV['SENDGRID_PASSWORD'],
:authentication => 'plain',
:enable_starttls_auto => true
}
There's also an example using the Mail gem, in the SendGrid documentation.
You could use your Gmail account.
In config > environment > production.rb
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => 'gmail.com',
:user_name => ENV['GMAIL_USER_NAME'],
:password => ENV['GMAIL_PASSWORD'],
:authentication => 'plain',
:enable_starttls_auto => true
}
Then you have to set GMAIL_USER_NAME and GMAIL_PASSWORD to Heroku configs
GMAIL_USER_NAME should be your email address of gmail domain eg. sample#gmail.com
I want to send emails from my rails application on Heroku.
As Heroku doesn't support SMTP, I use external SMTP server.
config/environments/production.rb has the following lines.
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:address => 'mydomain.com',
:port => 587,
:user_name => "myusername",
:password => "password",
:authentication => :plain,
:enable_starttls_auto => true,
:openssl_verify_mode => 'none'
}
When I send an email from "heroku run console", it works fine. But it doesn't send email from the website. Strangely, "heroku logs --tail" shows "Sent mail to ...". Actually the email is not delivered.
Does anyone have any idea about this issue?
Thanks.
Sam Kong
Have you tried this in config/enviornment.rb
ActionMailer::Base.smtp_settings = {
:address => 'mydomain.com',
:port => 587,
:user_name => "myusername",
:password => "password",
:authentication => :plain,
:enable_starttls_auto => true,
:openssl_verify_mode => 'none'
}
Your configuration is correct. But you have to put it in the correct environment file. In case of Heroku deployment, it should be 'production'. Console works because it uses 'development' as the environment. So put the following code in config/environment/production.rb
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:address => 'mydomain.com',
:port => 587,
:user_name => "myusername",
:password => "password",
:authentication => :plain,
:enable_starttls_auto => true,
:openssl_verify_mode => 'none'
}
Hope it solves your problem.
If it shows as mail as being sent that I would suggest that it's a config issue at your mail server perhaps preventing relay from the Heroku IP range - it's most odd though if it works through the heroku console and not through your application.
Have you thought of trying the SendGrid Heroku addon just to alleviate any issues with your own mailer server?
I tried to configure actionmailer to send via google apps with smtp.
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "mydomain.com",
:user_name => "username",
:password => "password",
:authentication => 'plain',
:enable_starttls_auto => true }
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
However whenever gitlab tries to send an e-mail:
Sent mail to user#my.domain.com (10ms)
Completed 500 Internal Server Error in 29ms
535-5.7.1 Username and Password not accepted
Server runs ruby 1.9.3p194. Why doesn't google apps accept the username/password?
It works now, I think the problem was with the username. it needs the domain in the username. i.e. the problem was
user_name: 'username'
Whereas the correct way (at least for google apps) is
user_name : 'username#mydomain.com'
this works for me:
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "gmail.com",
:user_name => "you#gmail.com",
:password => "password",
:authentication => 'plain',
:enable_starttls_auto => true }
Try setting the domain to gmail.com
I'm using sendgrid on heroku to send email in production, but would like to send email locally on my mac.
I've configured my development.rb a million different ways and keep getting
"Net::SMTPFatalError: 550 Cannot receive from specified address : Unauthenticated senders not allowed"
Spefically, I tried
varying authentication b/w :plain and :login,
tried using my gmail account credentials,
tried using my google app account credentials.
Nothing seems to work, thoughts?
config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_deliveries = true
ActionMailer::Base.smtp_settings = {
:address => 'smtp.gmail.com',
:domain => 'somedomain.com',
:port => 587,
:user_name => 'username#somedomain.com',
:password => 'somepassword',
:authentication => :plain,
:enable_starttls_auto => true
}
I thought I had set the in the production settings (production.rb), it turns out I had set them in environment.rb. Removed it there and everything started working.
I had set the mail settings by accident in the Environment.rb so it was overriding anything I was doing at the production/development config level.
Could you try this?
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "gmail.com",
:user_name => "email#gmail.com",
:password => "password",
:authentication => "plain",
:enable_starttls_auto => true
}