无法让 ActionMailer 通过 SMTP 与 MS Exchange 配合使用

发布于 2024-11-17 12:30:21 字数 1369 浏览 0 评论 0原文

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

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

:plain 错误:

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

:login 错误:

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)

无身份验证错误:

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

有什么想法吗?

Here's my simple test program (using 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

Trying various authentication types I get the following errors:

:plain error:

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

:login error:

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

:cram_md5 error:

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

No authentication error:

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

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

幽梦紫曦~ 2024-11-24 12:30:21

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

可能是:none、plain、login、cram_md5、NTLM、StartTLS

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

如何正确访问 Exchange

良好的资源,应该可以帮助您了解问题并对其进行故障排除。

如何您可以更改 Exchange 来解决问题

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

Redmine 特定

对 Ruby on Rails 的帮助

Check what authentication schemes are enabled

It could be: none, plain, login, cram_md5, NTLM, StartTLS

  • Using Telnet to connect to Exchange 2003 POP3 mailboxes and using SMTP to send e-mail for troubleshooting purposes

How to properly access Exchange

Good resources that should help you to understand and troubleshoot it.

How you could change Exchange to fix the problem

(instead of changing how you access Exchange)

Redmine specific

Helpful for Ruby on Rails

音盲 2024-11-24 12:30:21

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

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

had similar network issues. use the code below in irb to get debug info right in the console.

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)

never really found out what the issue was. they moved the exchange server and the production server stopped sending emails. im not really an IT guy but there were different debug logs depending which part of the network i was on. finally "solved" the problem by sending unauthenticated email...

依 靠 2024-11-24 12:30:21

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

telnet smtp.server.net 25
EHLO

服务器应响应至少一行以 250-AUTH 开头的行。之后列出了支持的身份验证方法。 Exchange 服务器可能仅支持通过 GSSAPI 或 NTLM 进行身份验证。在后一种情况下,您也许可以让它与 ruby​​-ntlm gem 和 ntlm 身份验证方法一起使用。 (请参阅 http://www.breckenedge .com/configuration-of-ruby-on-rails-actionmailer-for-microsoft-exchange-smtp

You could connect to the SMTP server and query the supported authentication methods:

telnet smtp.server.net 25
EHLO

The server should respond with at least one line that starts with 250-AUTH. After that the supported authentication methods are listed. Chances are that the Exchange server only supports authentication via GSSAPI or NTLM. In the latter case you might be able to get it to work with the ruby-ntlm gem and the ntlm authentication method. (See http://www.breckenedge.com/configuration-of-ruby-on-rails-actionmailer-for-microsoft-exchange-smtp)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文