无法使ActionMailer通过SMTP与MS Exchange一起使用

Edw*_*ler 8 ruby email exchange-server smtp ruby-on-rails-3

这是我的简单测试程序(使用ActionMailer 3.0.8,Ruby 1.9.2p180 Mac OS X):

require 'rubygems'
require 'action_mailer'

ActionMailer::Base.delivery_method = :smtp

ActionMailer::Base.smtp_settings = {
    :address => "my_exchange_server",
    :port => 25,
    :domain => 'my_domain.org',
    :authentication => :login,
    :user_name => 'my_user',
    :password => 'my_password',
    :enable_starttls_auto => false
}

ActionMailer::Base.raise_delivery_errors = true
ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.default :from => 'from_email@my_company.com'

m = ActionMailer::Base.mail :to => 'to_email@my_company.com', :subject => 'this is a test', :body => 'this is a test'
m.deliver
Run Code Online (Sandbox Code Playgroud)

尝试各种身份验证类型我收到以下错误:

:普通错误:

smtp.rb:966:in `check_auth_response': 504 5.7.4 Unrecognized authentication type. (Net::SMTPAuthenticationError)
Run Code Online (Sandbox Code Playgroud)

:登录错误:

smtp.rb:972:in `check_auth_continue': 504 5.7.4 Unrecognized authentication type. (Net::SMTPSyntaxError)
Run Code Online (Sandbox Code Playgroud)

:cram_md5错误:

smtp.rb:972:in `check_auth_continue': 504 5.7.4 Unrecognized authentication type. (Net::SMTPSyntaxError)
Run Code Online (Sandbox Code Playgroud)

没有验证错误:

protocol.rb:135:in `read_nonblock': end of file reached (EOFError)
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

E. *_*mbo 13

检查启用了哪些身份验证方案

它可能是:none,plain,login,cram_md5,NTLM,StartTLS

  • 使用Telnet连接到Exchange 2003 POP3邮箱并使用SMTP发送电子邮件以进行故障排除

如何正确访问Exchange

良好的资源,可以帮助您理解和排除故障.

如何更改Exchange以解决问题

(而不是更改您访问Exchange的方式)

Redmine具体

Ruby on Rails很有用


fir*_*ien 5

有类似的网络问题.使用下面的代码irb在控制台中获取调试信息.

require 'net/smtp'
smtp = Net::SMTP.new('ip_or_dns_address', port)
smtp.debug_output = $stdout
smtp.enable_starttls_auto#skip if not needed
smtp.start("domain", "user", "password", auth_type)
Run Code Online (Sandbox Code Playgroud)

从来没有真正发现问题是什么.他们移动了Exchange服务器,生产服务器停止发送电子邮件.我不是一个真正的IT人员,但根据我所在网络的哪个部分,有不同的调试日志.最后通过发送未经身份验证的电子邮件"解决"了问题...