8

So, one of my projects has a SMTP server that has been configured to be used without any form of authentication. Here is my SMTP setting on config/environments/production.rb.

config.action_mailer.asset_host = 'http://example.com'
config.action_mailer.default_url_options = { host: 'example.com' }
config.action_mailer.delivery_method = :smtp
config.action_mailer.raise_delivery_errors = true
config.action_mailer.smtp_settings = {
    address:              'mail.example.com',
    port:                587,
    domain:               'info.example.com',
    user_name:            '[email protected]',
    password:             '',
    openssl_verify_mode: 'none',
    authentication:       nil,
    tls:                  false,
    enable_starttls_auto: false
}

I though the authentication mode needs to be set to nil but, when I tried to send email, it gave me this error.

2.0.0-p481 :001 > CustomerMailer.test.deliver
Net::SMTPAuthenticationError: 503 5.5.1 Error: authentication not enabled

Any solution, guys?

1 Answer 1

12

You're specifying authentication details. ActionMailer will accordingly use them.

Solution: Don't.

config.action_mailer.smtp_settings = {
    address: 'mail.example.com',
    port:    587,
    domain:  'info.example.com'
}

(The domain parameter may itself be unnecessary depending on your server configuration.)

2
  • 1
    It gave me ArgumentError: SMTP-AUTH requested but missing secret phrase error. Commented Sep 29, 2014 at 6:53
  • I setup a local Postfix SMTP server for testing emails in my Rails app in dev. I also needed :openssl_verify_mode => 'none'. The domain wasn't required. In my development.rb I have this configuration: config.action_mailer.delivery_method = :smtp; config.action_mailer.smtp_settings = { :addres => 'localhost', :port => 25, :openssl_verify_mode => 'none'} Commented Feb 20, 2021 at 7:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.