I am using actionmailer to send registration verification details of devise to users but I am getting following error:
Net::OpenTimeout in Users::RegistrationsController#create
my development.rb looks like:
config.action_mailer.default_url_options = { :host => 'http://localhost:3000' }
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => 'smtp.gmail.com',
:port => 25,
:domain => 'gmail.com',
:user_name => 'example#gmail.com',
:password => 'secret',
:authentication => 'plain',
:enable_starttls_auto => true,
:ssl => true
}
I use this question and added
#disable ipv6
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
command:
cat /proc/sys/net/ipv6/conf/all/disable_ipv6
return 1. It didn't make difference to my error. Also tried changing port from 587 to 2525.
So I tried establish connection with server from command line:
telnet smtp.gmail.com 2525
got:
Trying 74.125.68.108...
Trying 74.125.68.109...
Trying 2404:6800:4003:c02::6c...
telnet: Unable to connect to remote host: Network is unreachable
I even tried adding firewall rules using this. I followed second method (ufw) but I am still getting same error.
Related
We're using successfully iRedMail in 4 email servers (8 domains) for our own email accounts.
We develop web apps based on RoR. We would like to know what is the iRedMail configuration for sending to users, via rails and devise gem, https://github.com/plataformatec/devise, the password reminds, emails confirmations, etc.. What is the difference between address and domain? How to test?
After Googling and posting in iRedMail forum unsuccessful, we only find smt gmail config, please find below.
Thanks in advance!
==== DEVISE config/environments/development.rb ====
SMTP GMAIL CONFIG:
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "mail.google.com",
:user_name => "my#gmail.com",
:password => "mypassword",
:authentication => :plain,
:enable_starttls_auto => true
}
==== BACK-END ====
iRedMail 0.9.7 MARIADB edition.
Debian GNU/Linux 9 (stretch) in a fresh OVZ-6GB
Mysql/MariaDB w/adminer
Apache/2.4.25 (Debian)
PHP 7.0.19-1
Ruby 2.5.0, Rails 5.1.5 and Phusion Passenger 5.2.1
No errors: /var/log/iredapd/iredapd.log
=============================
Editing DEVISE config/environments/development.rb
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
config.action_mailer.smtp_settings = {
:address => "mx.coopeu.com",
:port => 587,
:domain => "mx.cooopeu.com",
:user_name => "coopeu#coopeu.com",
:password => "password",
:authentication => :plain,
:enable_starttls_auto => true
}
Also raising error:
Net::SMTPFatalError in ConfirmationsController#create
554 5.7.1 : Recipient address rejected: Sender is not same as SMTP authenticate username
It means you use user "coopeu#coopeu.com" for SMTP authentication, but specify user "someone-else#somedomain.com" as the sender address.
If you need to allow the sender address mismatch for this smtp user, you can add one setting in
/opt/iredapd/settings.py
to allow it, like below:
ALLOWED_LOGIN_MISMATCH_SENDERS = ['coopeu#coopeu.com']
Restarting iredapd after modified "settings.py".
and it's working right
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/
I am facing problem with Open SSL certificate error while sending email in production server. Everything is working fine in development mode. Below is my configuration code in production mode.
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:authentication => "plain",
:enable_starttls_auto => true,
:user_name => 'xxxxxxx',
:password => 'xxxxx',
:openssl_verify_mode => 'none'
}
I have already looked at the solution in previous post But, that does not solve my problem.
Could anyone kindly help with this one?
Try adding the domain name in smtp_setings
:domain => 'www.your-domain-name.com'
Anyone have luck configuring ActionMailer to send email via a Zoho account?
These are my settings:
ActionMailer::Base.smtp_settings = {
:address => "smtp.zoho.com",
:port => 465,
:domain => 'example.com',
:user_name => 'steve#example.com',
:password => 'n0tmypa$$w0rd',
:authentication => :login
}
However, calling .deliver times out:
irb(main):001:0> AdminMailer.signup_notification('asfd').deliver
Timeout::Error: Timeout::Error
from C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:146:in `rescue in rbuf_fill'
from C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:140:in `rbuf_fill'
from C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:122:in `readuntil'
from C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:132:in `readline'
from C:/Ruby193/lib/ruby/1.9.1/net/smtp.rb:929:in `recv_response'
from C:/Ruby193/lib/ruby/1.9.1/net/smtp.rb:552:in `block in do_start'
from C:/Ruby193/lib/ruby/1.9.1/net/smtp.rb:939:in `critical'
from C:/Ruby193/lib/ruby/1.9.1/net/smtp.rb:552:in `do_start'
from C:/Ruby193/lib/ruby/1.9.1/net/smtp.rb:519:in `start'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/mail-2.4.4/lib/mail/network/delivery_methods/smtp.rb:144:in `deliver!'
The help docs say to use port 465 and SSL authentication. I've tried with and without :enable_starttls_auto => true but it still times out.
Specifically, the docs specify the following settings:
> Email Address: Username#yourdomain.com
> User Name format: Username#yourdomain.com
> Secure Connection (SSL) Yes
> Outgoing Mail Server Name: smtp.zoho.com
> Outgoing Port No.: 465
> Outgoing Mail Server requires authentication: Yes
Any ideas?
p.s. I've configured Outlook to use the settings in the help docs and outgoing email works fine. telnet to smtp.zoho.com 465 also connects.
# Action Mailer
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:address => "smtp.zoho.com",
:port => 465,
:user_name => 'someone#somewhere.com',
:password => 'password',
:authentication => :login,
:ssl => true,
:tls => true,
:enable_starttls_auto => true
}
That worked for me. Your settings might be fine some local networks block these kinds of packets. I had to test it through my 3G network.
FYI:
Let's say your domain is abc.com.
Let's say you have 'default from' on your mailer with a different domain, e.g.
default from: "\"Elephant\" <el#ephant.com>"
This will not work unless you change your 'default from' using the same domain on your zoho account.
So,
default from: "\"Elephant\" <el#abc.com>"
will work.
I'm not sure if Zoho have changed their security settings, but #Tyrel Richey's accepted answer didn't work for me. However, the following does:
/config/initializers/action_mailer.rb..
# ActionMailer email configuration
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:address => ENV['SMTP_ADDRESS'],
:port => ENV['SMTP_PORT'],
:domain => ENV['SMTP_DOMAIN'],
:user_name => ENV['SMTP_USERNAME'],
:password => ENV['SMTP_PASSWORD'],
:authentication => :login,
:enable_starttls_auto => true
}
Where..
:address = smtp.zoho.com
:port = 587
:domain is localhost in development, and the live URL in production (e.g. example.com)
I have mail sending with Rails 4.2.3 like so...
# config/environments/development.rb
Rails.application.configure do
#...
config.action_mailer.default_url_options = { host: 'domain' }
config.action_mailer.smtp_settings = { address: 'smtp.zoho.com', port: 465, user_name: 'username#domain.com', password: 'mypassword', authentication: :login, ssl: true }
end
You can of course use this in production as well by adding this to config/environments/production.rb
I also set the email address in config/initializers/devise.rb so I can send password reset instruction.
config.mailer_sender = 'noreply#truhawk.com'
References
https://www.zoho.com/mail/help/zoho-smtp.html
http://guides.rubyonrails.org/action_mailer_basics.html
These settings worked for me in production.
Rails.application.routes.default_url_options[:host] = 'eyehawk.io'
config.action_mailer.default_url_options = { :host => 'eyehawk.io' }
config.action_mailer.perform_caching = false
config.action_mailer.delivery_method = :smtp
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.zoho.com",
:port => 587,
:domain => "zoho.com",
:user_name => "admin#eyehawk.io",
:password => ENV['SMTP_PASSWORD'],
:authentication => :plain,
:enable_starttls_auto => true
}
Using smtp.zoho.eu instead of smtp.zoho.com as address did the trick for me.
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'],