Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails ActionMailer Send Email Without Authentication

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?

like image 774
Edwin Lunando Avatar asked Sep 29 '14 06:09

Edwin Lunando


1 Answers

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.)

like image 198
colinm Avatar answered Nov 06 '22 19:11

colinm