0

After reading through many posts I couldn't find a solution to my problem. I've made a test connection with www.smtper.net which was successful. My error.log only tells me the error:

OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=unknown state: unknown protocol


app/controllers/passwords_controller.rb:11:in `create'

Maybe it has something to do with my nginx settings?

Issue

I'm trying to configure my smtp via mailgun (or gmail) but without success. My configuration in developement.rb looks like:

config.action_mailer.default_url_options = { :host => "xxxxx:8765" } 
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.smtp_settings = {
   :address => "smtp.gmail.com",
   :port => 587,
   :domain => "mail.google.com",
   :user_name => "xxx@gmail.com",
   :password => "xxxxxx",
   :authentication => :plain,
   :enable_starttls_auto => true
}

And the error is thrown at the action create, line 11:

  AccountMailer.password_reset_email(@account).deliver

I have installed OpenSSL 1.0.1f on my development server

TRACE

/root/.rbenv/versions/2.5.1/lib/ruby/2.5.0/net/protocol.rb:44:in `connect_nonblock'
/root/.rbenv/versions/2.5.1/lib/ruby/2.5.0/net/protocol.rb:44:in `ssl_socket_connect'
/root/.rbenv/versions/2.5.1/lib/ruby/2.5.0/net/smtp.rb:584:in `tlsconnect'
/root/.rbenv/versions/2.5.1/lib/ruby/2.5.0/net/smtp.rb:552:in `do_start'
/root/.rbenv/versions/2.5.1/lib/ruby/2.5.0/net/smtp.rb:518:in `start'
mail (2.7.0) lib/mail/network/delivery_methods/smtp.rb:109:in `start_smtp_session'
mail (2.7.0) lib/mail/network/delivery_methods/smtp.rb:100:in `deliver!'
mail (2.7.0) lib/mail/message.rb:2160:in `do_delivery'
mail (2.7.0) lib/mail/message.rb:260:in `block in deliver'
actionmailer (4.2.8) lib/action_mailer/base.rb:543:in `block in deliver_mail'
activesupport (4.2.8) lib/active_support/notifications.rb:164:in `block in instrument'
activesupport (4.2.8) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.2.8) lib/active_support/notifications.rb:164:in `instrument'
actionmailer (4.2.8) lib/action_mailer/base.rb:541:in `deliver_mail'
mail (2.7.0) lib/mail/message.rb:260:in `deliver'
actionmailer (4.2.8) lib/action_mailer/message_delivery.rb:85:in `deliver_now'
actionmailer (4.2.8) lib/action_mailer/message_delivery.rb:105:in `deliver'
app/controllers/passwords_controller.rb:11:in `create'
Rick Grimes
  • 103
  • 10

1 Answers1

0

What happens if you try this settings and get rid of everything else you currently have:

# /config/environments/development.rb

# Gmail configuration
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:               'example.com',
  user_name:            ENV['EMAIL_USER'],
  password:             ENV['EMAIL_PASS'],
  authentication:       'plain',
  enable_starttls_auto: true
}

I'm not sure you need to monkey with smtper.net but perhaps see this, even though it's very old, it probably should still work:

http://blog.napcs.com/2013/07/21/rails_ssl_simple_wa/

You'll need to set those environment variables as you obviously should never want to commit credentials in your git repo.

But also see these posts as you may need to do some other things for gmail

(Ruby) Getting Net::SMTP working with Gmail...?

Rails 4, how to correctly configure smtp settings (gmail)

lacostenycoder
  • 10,623
  • 4
  • 31
  • 48
  • Thanks for the links, but I've already taken a look at them. Authentication type password does not exist, but tried it also with :login – Rick Grimes Oct 31 '18 at 10:41
  • oh yeah my mistake, I meant `:login` and updated. But I guess it doesn't solve your problem? Can we see your controller code? – lacostenycoder Oct 31 '18 at 10:53