What is wrong with my Rails SMTP config? - ruby-on-rails

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.

Related

Rails: Send emails from namecheap email address

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.

Rails w/devise authentication what is the configuration of iRedMail?

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

Why can't I see any emails in my inbox sent from my Heroku Rails app using SendGrid SMTP Relay in development mode?

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.

Rails 3.2 email sent via smtp is flagged as unencrypted by gmail

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.

Rails Action Mailer TLS Certificate Issues

I am trying to use rackspace ssl smtp for my mail settings for our rails application and I am receiving this error
hostname was not match with the server certificate
I need to find a way to disable verify on the certs for ActionMailer.
Anyone know how to do this?
Try setting enable_starttls_auto to false in your smtp_settings:
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.raise_delivery_errors = true
ActionMailer::Base.default_charset = "utf-8"
ActionMailer::Base.smtp_settings = {
:address => 'server.com',
:port => '25',
:domain => 'yourdomain.com',
:user_name => 'username',
:password => 'password',
:authentication => :login,
:enable_starttls_auto => false
}
For some reason I can't comment on Derek's answer, but his answer does in fact work now with Rackspace. Simply changing tls to false now works great.
Resolved issue by using sendmail and configuring sendmail to use the proper smtp settings required to use rackspace email hosting.

Resources