Ruby/Rails ActionMailer not working with NTLM

后端 未结 3 1868
深忆病人
深忆病人 2021-01-22 02:06

I am setting up a mailer in my project and I am having difficulties sending mail through Exchange SMTP server.

I have installed the gem ruby-ntlm but I am s

相关标签:
3条回答
  • 2021-01-22 02:24

    This is because you haven't included the ntlm library.

    Add the NTLM SMTP library to your config/environment.rb file

    # Load the Rails application.
    require File.expand_path('../application', __FILE__)
    
    require 'ntlm/smtp' # ADD THIS LINE HERE
    
    # Initialize the Rails application.
    Rails.application.initialize!
    
    0 讨论(0)
  • 2021-01-22 02:30

    Found a typo, it is now working!

    development.rb

    Change :authentification => :ntlm to :authentication => :ntlm

    Thanks for the support anyway!

    0 讨论(0)
  • 2021-01-22 02:44

    Add the ruby-ntlm gem to your Gemfile and run bundle install.

    Gemfile:

      gem 'ruby-ntlm'
    

    bundle install

    Add the NTLM SMTP library to your config/environment.rb file.

    # Load the rails application
    require File.expand_path('../application', __FILE__)
    require 'ntlm/smtp'
    
    # Initialize the rails application
    RailsApp::Application.initialize!
    

    Set up your environment file to authenticate with NTLM.

    config.active_support.deprecation = :notify
    config.action_mailer.delivery_method = :smtp
    config.action_mailer.smtp_settings = {
      :address => '<your-email-server>',          # mail.example.com
      :domain => '<your-domain>',                 # example.com
      :user_name => '<your-username>',            # user.name
      :password => '<your-unencrypted-password>', # p@ssw0rd
      :port => 25,
      :authentication => :ntlm
    }
    

    Finally, make sure you change your default from whatever email address you’ve been using to reflect the new Microsoft Exchange account, or you’ll receive a 5.7.1 Client does not have permissions to send as this sender error.

    0 讨论(0)
提交回复
热议问题