Search code examples
ruby-on-railsexchange-serveractionmailerexchange-server-2010

ActionMailer with NTLM auth (Exchange 2010)


I have this Rails Application Using Rails 4.2. How can I send mail using an Exchange 2010 server with NTLM authentication? According to ActionMailer docs:

:authentication - If your mail server requires authentication, you need to specify the authentication type here. This is a symbol and one of :plain (will send the password Base64 encoded), :login (will send the password Base64 encoded) or :cram_md5 (combines a Challenge/Response mechanism to exchange information and a cryptographic Message Digest 5 algorithm to hash important information)

Whatever auth method I chose, I keep getting this error:

Net::SMTPSyntaxError: 504 5.7.4 Unrecognized authentication type

Solution

  • So I found the solution myself. I kept getting this error because the Exchange server I use requires no authentication, so you should not pass any authentication option at all:

    config.action_mailer.smtp_settings = {
      address:              'smtp.yourdomain.com',
      port:                 587,
      domain:               'yourdomain.com'
    }
    

    Yes thats right: user_name, passwod and authentication are left out.