无法让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发送电子邮件以进行故障排除
- http://www.msexchange.org/tutorials/telnet-exchange2003-pop3-smtp-troubleshooting.html
- 向下滚动到: 连接到SMTP
- EHLO的回归是什么?
- “
250-AUTH LOGIN
”或“250-AUTH=LOGIN
”表示您需要进行身份validation。 - “
250-AUTH
”(在该行上没有其他任何内容!)似乎表明你不应该自己validation ! 否则你会收到错误:- “504 5.7.4无法识别的身份validation类型”
- “
- http://www.msexchange.org/tutorials/telnet-exchange2003-pop3-smtp-troubleshooting.html
如何正确访问Exchange
良好的资源,可以帮助您理解和排除故障。
- EHLO动词和SMTP扩展
- AUTH命令
- 如何使用Telnet将SMTP电子邮件发送到Exchange 2007和2010
- 使用telnet测试Exchange中经过身份validation的中继
如何更改Exchange以解决问题
(而不是更改您访问Exchange的方式)
- 如何在smtp服务器交换2010上启用auth登录
- 如何在Exchange上启用“身份validation登录”身份validation
- 建立SMTP连接时出错,错误:504 5.7.4无法识别的身份validation类型
- (如何将Exchange 2010配置更改为“ 接受来自第三方产品的邮件 ”,如Anil K Singh所述 )
Redmine具体
Ruby on Rails很有用
- 如何配置Redmine以邮件到MS Exchange服务器
- http://www.redmine.org/projects/redmine/wiki/HowTo_configure_Redmine_to_mail_to_MS_Exchange_server
- “MS Exchange不会要求传出(SMTP)电子邮件的身份validation信息”
- 我的配置文件仍在config / email.yml (在Redmine 1.2中)
- http://www.redmine.org/projects/redmine/wiki/HowTo_configure_Redmine_to_mail_to_MS_Exchange_server
- Ruby on Rails代码的有用故障排除技巧
- 请参阅firien的回答
- 如果Exchange需要NTLM,如何使用ruby-ntlm
- 从Rails执行Auth到Exchange时无法识别的身份validation类型
- 如何使用TLS选项
有类似的网络问题。 使用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 )