I'm using Sendgrid on a Rails 5.2 application and was getting a
Net::ReadTimeout
error when trying to send an email. The post here
https://github.com/mikel/mail/issues/639#issuecomment-29016055 suggested adding :tls => true
to the SMTP settings. That worked, but it seems like an old solution and I'd like to understand what it's doing and why it worked.
This is my SMTP setup that gave the Net::ReadTimeout
error:
ActionMailer::Base.smtp_settings = {
:user_name => 'username',
:password => 'password',
:domain => 'mydomain.com',
:address => 'smtp.sendgrid.net',
:port => 465,
:authentication => :plain,
:enable_starttls_auto => true
}
This is the update that's working.
ActionMailer::Base.smtp_settings = {
:user_name => 'username',
:password => 'password',
:domain => 'mydomain.com',
:address => 'smtp.sendgrid.net',
:port => 465,
:authentication => :plain,
:enable_starttls_auto => true,
# this line added
:tls => true
}
For reference