I'm getting the following error when trying to send an email notification:
Connection refused - connect(2) for "mail.privateemail.com" port 25
I'm in development mode and this is the setup I have:
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => 'mail.privateemail.com',
:port => 25,
:user_name => 'my_email_address_here',
:password => 'password_here',
:authentication => :plain,
:enable_starttls_auto => true }
Any idea what I might be doing wrong here?
Namecheap uses ports 465 for SSL, and 25/587 for TLS/STARTTLS. Additional to this, you must disable SPA in the Namecheap dashboard in order to send emails outside of their dashboard. So I would say all you need to do is disable SPA from the dashboard and you'll be good to go.
As a side note, be sure to store your email address and password in environment variables to keep your credentials out of any version control you may be using.
Related
I'm building a web app with Rails.
In the production environment, I want to use Mailgun to send account verification emails, but when I register with an address other than the ones I've authenticated and I am using for Heroku, I get the following error and can't send the emails.
Net::SMTPUnknownError (could not get 3xx (421: 421 Domain sandbox3fb706e74ad5432f99a8627384de2867.mailgun.org is not allowed to send: Sandbox subdomains are for test purposes only. Please add your own domain or add the address to authorized recipients in Account Settings.
Here is my production.rb
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
host = 'protected-island-35085.herokuapp.com'
config.action_mailer.default_url_options = { host: host }
ActionMailer::Base.smtp_settings = {
:port => ENV['MAILGUN_SMTP_PORT'],
:address => ENV['MAILGUN_SMTP_SERVER'],
:user_name => ENV['MAILGUN_SMTP_LOGIN'],
:password => ENV['MAILGUN_SMTP_PASSWORD'],
:domain => host,
:authentication => :plain,
}
I'm having trouble with this because I can't send emails to users after releasing the application.
The idea that Email cannot be sent to not-verified address if I use free-plan of Mailgun has come up to me, is that right?
How can I make it so that I can send emails to other addresses properly?
Also, if there is any missing information, please let me know and I will add it.
I'm trying to switch over to SendGrid from Mandrill in my Rails 4.2 app through SendGrid's SMTP Relay. I have set the 'To Email' to be my personal email address so that I can view the emails that have been sent, however none of the emails actually appear in my inbox despite the rails console claiming to have processed and sent the email.
I am fairly certain all my mailers have the appropriate smtp settings as I have mostly followed the instructions provided on the SendGrid website: https://sendgrid.com/docs/Integrate/Frameworks/rubyonrails.html
I have also tested my connectivity to SendGrid's SMTP Relay through telnet and the connection is succesful.
My SendGrid dashboard indicated that 0 emails have been sent. None of my emails appear under the Suppressions tab either so it's not like they have bounced or have been blocked.
This is in my config/environment.rb:
ActionMailer::Base.smtp_settings = {
:user_name => 'apikey',
:password => ENV['SENDGRID_API_KEY'],
:domain => 'heroku.com',
:address => 'smtp.sendgrid.net',
:port => 587,
:authentication => :plain,
:enable_starttls_auto => true
}
This is in my config/environments/development.rb:
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.default_url_options = { :host => 'smtp.sendgrid.net' }
This is the line in my controller that calls my ApplicationMailer:
ApplicationMailer.send_email(user, 'mypersonalemail#email.com', 'Test Subject').deliver
And this is what gets printed in the console when the mailer method is executed:
ApplicationMailer#send_email: processed outbound mail in 789.9ms
Sent mail to mypersonalemail#email.com (103.4ms)
But I still don't get any emails in my inbox or spam folder. Does anyone know how I can solve this? Thanks in advance.
Your domain and host options are wrong. Use localhost:3000 (unless you're using docker or something at which point replace localhost:3000 with 0.0.0.0:8000)
#/environments/development.rb
#Mailer Options
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
ActionMailer::Base.smtp_settings = {
:address => 'smtp.sendgrid.net',
:port => '587',
:authentication => :plain,
:user_name => ENV['SENDGRID_USERNAME'],
:password => ENV['SENDGRID_PASSWORD'],
:domain => 'localhost:3000',
:enable_starttls_auto => true
}
config.action_mailer.default_url_options = { host: 'http://localhost:3000' }
config.action_mailer.asset_host = 'http://localhost:3000'
Make sure to add the sendgrid credentials to your local machine as environment vars. To get them, go to your heroku app and click on settings, then "reveal config vars". Then add those sendgrid credentials to your local machine as env. vars and you're done.
I have rails app which uses devise ofr authentication and sidekiq for background email jobs. All of a sudden, in development only, I am getting the following error associated with an attempt to send an email from the app (e.g. devise forgotten password)
EOFError: end of file reached
Strangely the app in production works (heroku set up using sendgrid). I haven't changed any of my development email settings....
ActionMailer::Base.default :from => 'slfwalsh#gmail.com'
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => '#gmail.com',
:user_name => "xxxxx#gmail.com",
:password => "xxxxxxxx",
:authentication => 'plain',
:enable_starttls_auto => true
}
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
I can't find anything to address this online. Also I note that ALL my apps in development, using similar settings are throwing the same error. I tried a different email address and password (again gmail) and no luck....
For those like Aleksey wondering how the problem was solved, he added a valid domain. Went from domain: '#gmail.com' to domain: "myprojectdomain.com"
For me, setting sender email in my Devise config file fixed the issue.
I have got EOFError: end of file reached issue after migration from EC2 to ECS deployment.
Following is short way to diagnose issue.
$ telnet smtp.sendgrid.net 587
Trying 167.89.118.51...
Connected to smtp.sendgrid.net.
Escape character is '^]'.
220 SG ESMTP service ready at ismtpd0009p1las1.sendgrid.net
...
In case when you don't see kind of 220 greeting from the server after connection, it may mean that something sitting between your client and SMTP server and blocks connection. In our case it was AppMesh proxy which is blocking smtp.
Next test is
openssl s_client -crlf -starttls smtp -connect smtp.sendgrid.net:587
which should show a lot info about SSL.
If you can't see expected info by this tests check your infrastructure first, neither smtp settings will work.
Note that 587 is standard replacement for 25. It is expected that client send STARTTLS to obtain SSL connection. While another alternative - 465 expected to connect with SSL by default.
More details: https://aws.amazon.com/premiumsupport/knowledge-center/smtp-connectivity-timeout-issues-ses/
For those who are stuck....this worked but I unclear why.
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
address: "smtp.gmail.com",
port: 587,
domain: "myprojectdomain.com",
user_name: "xxxx#gmail.com",
password: "xxxx",
authentication: 'plain',
enable_starttls_auto: true
}
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
I had this same issue. The problem was that I was using the Imap host setting (imap.gmail.com) for Smtp host setting (smtp.gmail.com).
Here's how I solved it:
I simply replaced the host
imap.gmail.com
with
smtp.gmail.com
That's all.
I hope this helps.
I would like to ask what I missed why my email was flagged as unencrypted by Gmail. My project uses Hostmonster.com no-reply account to send email.
Rails smtp settings:
config.action_mailer.default_url_options = { host: APP_CONFIG[:host], port: APP_CONFIG[:port], protocol: "https" }
config.action_mailer.perform_deliveries = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "host289.hostmonster.com",
:port => 465,
:domain => APP_CONFIG[:smtp][:domain],
:user_name => APP_CONFIG[:smtp][:user_name],
:password => APP_CONFIG[:smtp][:password],
:authentication => "plain",
:enable_starttls_auto => true,
:ssl => true
}
Hostmonster cpanel:
enter image description here
The project is already in HTTPS. I don't know if it's in my end causing the Gmail unencrypted issues or on hostmonster.
enter image description here
I believe this is rather about the configuration of the hosting SMTP server when talking to GMail servers. You are sending your email to the hostmonster SMTP server via encrypted SMTP connection, which is correct. But it's the hostmonster's responsibility to also send the mail encrypted further on, which they probably don't do.
I would contact the hostmonster's support about this issue, i.e. ask them if they use encrypted communication when sending outgoing emails from their servers.
I was given this smtp server address: klee.cdlib.org (behind our firewall and does not need password/login) and my own local address where my dev application is running is http://128.48.204.195:3000
Here are my current configurations in the development.rb file:
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "klee.cdlib.org",
:port => 587,
:domain => 'klee.cdlib.org', #'http://128.48.204.195:3000',
# :user_name => '',
# :password => '',
:authentication => 'plain',
:enable_starttls_auto => true }
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
This gives an error:
Net::SMTPFatalError (550 5.7.1 <my#email.com>... Relaying denied
I am also not sure about the difference between domain and address fields. What should be in which? :) And what else am I possibly doing wrong to get this error?
Thanks,
Alex
Your rails setup seems ok. Denied relaying is probably raised because the mail server actually does not allow relaying any mails for mails from 128.48.204.195. It's possible that the mail server configuration is not configured for that or perhaps it's configured to relay mails from klee.cdlib.org which has no reverse DNS entry.