如何通过Rails 2.1.1上的Exchange Server 2013发送邮件?

时间:2016-06-29 12:31:10

标签: email smtp ruby-on-rails-2 ruby-1.8 exchange-server-2013

我们有一个6年前建立的旧应用程序。 将邮件服务器从 Exchange Server 2007 升级到 Exchange Server 2013 后,我们收到此错误“ 504 5.7.4无法识别的身份验证类型”。< / p>

如果没有升级rails版本,有没有解决这个错误?

OS
Microsoft Windows Server 2003标准版Service Pack 2

InstantRails 2.0

的environment.rb

config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
    :address => "mail-server",
    :port => 25,
    :domain => "domain.com",
    :authentication => :login,
    :user_name => "username",
    :password => "password",
    :enable_strttls_auto => true,
    :openssl_verify_mode => "none"
}
config.action_mailer.raise_delivery_errors = true
config.action_mailer.perform_deliveries = true
config.action_mailer.default_charset = 'utf-8'

user_mailer.rb

  #using fake outlook account
  def test_notification_fake
    @subject = "Dev - APP | Testing Email_fake."
    @body = {}
    # Give body access to the user information.
    @recipients = 'recipient@gmail.com'
    @bcc = $adminemail
    @content_type = "text/html"
    @from = 'APP | do-not-reply email <fake@domain.com>'
  end

  #using real outlook account
  def test_notification_real        
    @subject = "Dev - APP | Testing Email_real."
    @body = {}
    # Give body access to the user information.
    @recipients = 'recipient@gmail.com'
    @bcc = $adminemail
    @content_type = "text/html"
    @from = 'APP | do-not-reply email <real@domain.com>'
  end

master_controller.rb

def index
    UserMailer.deliver_test_notification_fake    
    UserMailer.deliver_test_notification_real

gem env

C:\InstantRails\rails_apps>gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 1.4.0
  - RUBY VERSION: 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32]
  - INSTALLATION DIRECTORY: C:/InstantRails/ruby/lib/ruby/gems/1.8
  - RUBY EXECUTABLE: C:/InstantRails/ruby/bin/ruby.exe
  - EXECUTABLE DIRECTORY: C:/InstantRails/ruby/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-mswin32-60
  - GEM PATHS:
     - C:/InstantRails/ruby/lib/ruby/gems/1.8
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
     - :gempath => ["C:/InstantRails/ruby/lib/ruby/gems/1.8"]
     - :sources => ["http://gems.rubyforge.org/", "http://gems.github.com/", "ht
tp://rubygems.org/", "http://gemcutter.org/"]
     - "gem" => "--no-rdoc --no-ri"
  - REMOTE SOURCES:
     - http://gems.rubyforge.org/
     - http://gems.github.com/
     - http://rubygems.org/
     - http://gemcutter.org/

宝石列表

C:\InstantRails\rails_apps>gem list

*** LOCAL GEMS ***

actionmailer (2.1.1, 2.0.2)
actionpack (2.1.1, 2.0.2)
activerecord (2.1.1, 2.0.2)
activerecord-odbc-adapter (2.0)
activerecord-sqlserver-adapter (1.0.0.9250)
activeresource (2.1.1, 2.0.2)
activesupport (2.1.1, 2.0.2)
acts_as_tree (0.1.1)
archive-tar-minitar (0.5.2)
builder (2.1.2)
capistrano (2.5.0, 2.1.0)
capistrano-ext (1.2.1)
cgi_multipart_eof_fix (2.5.0)
chronic (0.10.2)
cmdparse (2.0.2)
color (1.4.0)
columnize (0.2)
dbd-odbc (0.2.4)
dbi (0.4.1)
deprecated (2.0.1)
exifr (0.10.9)
fastercsv (1.5.1)
fattr (2.2.0)
flexmock (0.9.0)
fxri (0.3.7, 0.3.6)
fxruby (1.6.16 x86-mswin32-60, 1.6.12 mswin32)
gem_plugin (0.2.3)
highline (1.4.0)
hoe (1.5.1)
i18n (0.6.9)
ldap (0.9.7 mswin32)
linecache (0.43 mswin32)
log4r (1.0.5)
minitest (4.7.5, 2.1.0)
mongrel (1.1.5 x86-mswin32-60, 1.1.2 mswin32)
mongrel_service (0.3.4 i386-mswin32)
multi_json (1.8.4)
mysql (2.7.3 mswin32)
needle (1.3.0)
net-scp (1.0.1)
net-sftp (2.0.1, 1.1.0)
net-ssh (2.0.4, 1.1.2)
net-ssh-gateway (1.0.0)
pdf-writer (1.1.8)
rails (2.1.1, 2.0.2)
rake (0.8.2, 0.8.1, 0.8.0, 0.7.3)
rcov (0.8.1.2.0 mswin32)
rio (0.4.1)
rmagick (2.0.0 mswin32)
ruby-breakpoint (0.5.1)
ruby-debug (0.10.2)
ruby-debug-base (0.10.2 mswin32)
ruby-net-ldap (0.0.4)
ruby-ntlm (0.0.1)
ruby-ole (1.2.11.1)
ruby-openid (2.1.2, 2.0.4)
rubyforge (0.4.4)
rubygems-update (1.4.0, 1.3.0, 1.2.0, 1.0.1)
rubyzip (0.9.4)
session (3.1.0)
sources (0.0.1)
spreadsheet (0.6.5.4)
sqlite3-ruby (1.2.1 mswin32)
to_excel (1.0)
to_xls (1.0.0)
transaction-simple (1.4.0)
tzinfo (0.3.38, 0.3.11)
wicked_pdf (0.7.2)
will_paginate (2.3.16, 2.3.12)
win32-api (1.2.2 x86-mswin32-60, 1.2.0 x86-mswin32-60, 1.0.4 mswin32)
win32-clipboard (0.4.4, 0.4.3)
win32-dir (0.3.2)
win32-eventlog (0.4.9, 0.4.6)
win32-file (0.5.5, 0.5.4)
win32-file-stat (1.3.1, 1.2.7)
win32-open3 (0.3.2 x86-mingw32)
win32-process (0.5.9, 0.5.3)
win32-sapi (0.1.4)
win32-service (0.6.1 x86-mswin32-60, 0.5.2 mswin32)
win32-sound (0.4.1)
windows-api (0.2.4, 0.2.0)
windows-pr (0.9.2, 0.7.2)
writeexcel (1.0.5)
xmpp4r (0.4)

C:\InstantRails\rails_apps>

1 个答案:

答案 0 :(得分:0)

我遇到了这个问题:504 5.7.4无法识别的身份验证类型

发送用户名和密码参数时。

我认为这取决于您的MS Exchange服务器配置。解决了我的配置测试设置的所有组合。

我的设置位于config / environments / develop.rb:

# localhost because is in development
    config.action_mailer.default_url_options = { host: "127.0.0.1:3000" }
    config.active_support.deprecation = :notify
    config.action_mailer.delivery_method = :smtp
    config.action_mailer.smtp_settings = {

      :address =>              'mail.yourmailserver.com',
      :port =>                 25, # verify your port
      :domain =>               'yourmailserver.com',
      :openssl_verify_mode => 'none', # my server doesnt use openssl
      :enable_starttls_auto => false # i don't know why but it requires

    }

希望它有所帮助。