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

这是我的简单测试程序(使用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 

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

:普通错误:

 smtp.rb:966:in `check_auth_response': 504 5.7.4 Unrecognized authentication type. (Net::SMTPAuthenticationError) 

:登录错误:

 smtp.rb:972:in `check_auth_continue': 504 5.7.4 Unrecognized authentication type. (Net::SMTPSyntaxError) 

:cram_md5错误:

 smtp.rb:972:in `check_auth_continue': 504 5.7.4 Unrecognized authentication type. (Net::SMTPSyntaxError) 

没有validation错误:

 protocol.rb:135:in `read_nonblock': end of file reached (EOFError) 

有任何想法吗?

检查启用了哪些身份validation方案

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

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

如何正确访问Exchange

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

如何更改Exchange以解决问题

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

Redmine具体

Ruby on Rails很有用

有类似的网络问题。 使用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) 

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

您可以连接到SMTP服务器并查询支持的身份validation方法:

 telnet smtp.server.net 25 EHLO 

服务器应至少响应一行以250-AUTH开头的行。 之后列出支持的身份validation方法。 有可能Exchange服务器仅支持通过GSSAPI或NTLM进行身份validation。 在后一种情况下,您可以使用ruby-ntlm gem和ntlm身份validation方法。 (见http://www.breckenedge.com/configuration-of-ruby-on-rails-actionmailer-for-microsoft-exchange-smtp )