ActionMailer和Exchange

时间:2009-11-18 09:47:57

标签: ruby-on-rails smtp exchange-server actionmailer

我使用我的Rails应用程序和Postfix服务器成功通过SMTP发送邮件。现在我需要转到Exchange:Microsoft ESMTP MAIL服务,版本:6.0.3790.3959,启用了POP3和SMTP支持。

我使用actionmailer 1.2.5并且在尝试发送邮件时无法成功登录服务器。

如果我使用Mail.app发送和接收工作正常,只要我将身份验证架构更改为“密码”。检查服务器如下所示:

READ Nov 18 10:37:00.509 [kCFStreamSocketSecurityLevelNone]  -- host:mail.my-mail-server-domain.com -- port:25 -- socket:0x11895cf20 -- thread:0x11b036a10
250-mail.my-mail-server-domain.com Hello [xxx.xxx.xxx.xxx]
250-TURN
250-SIZE
250-ETRN
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-8bitmime
250-BINARYMIME
250-CHUNKING
250-VRFY
250-X-EXPS GSSAPI NTLM LOGIN
250-X-EXPS=LOGIN
250-AUTH GSSAPI NTLM LOGIN
250-AUTH=LOGIN
250-X-LINK2STATE
250-XEXCH50
250 OK

WROTE Nov 18 10:37:00.852 [kCFStreamSocketSecurityLevelNone]  -- host:mail.my-mail-server-domain.com -- port:25 -- socket:0x11895cf20 -- thread:0x11b036a10
AUTH LOGIN

READ Nov 18 10:37:01.848 [kCFStreamSocketSecurityLevelNone]  -- host:mail.my-mail-server-domain.com -- port:25 -- socket:0x11895cf20 -- thread:0x11b036a10
235 2.7.0 Authentication successful.

所以验证方法:登录似乎得到了适当的支持。现在谈到我对actionmailer的配置时,它看起来是这样的:

ActionMailer::Base.server_settings = {
    :address => "mail.my-mail-server-domain.com",
    :port => 25,
    :domain => "my-mail-server-domain.com",
    :authentication => :login,
    :user_name => "myusername",
    :password => "mypassword"
}

我一遍又一遍地收到身份验证错误。我也试图改变

    :user_name => "my-mail-server-domain.com\myusername"
    :user_name => "my-mail-server-domain.com\\myusername"
    :user_name => "myusername/my-mail-server-domain.com"
    :user_name => "myusername@my-mail-server-domain.com"

但没有任何作用。谁能帮我?

的问候。 杰森

1 个答案:

答案 0 :(得分:1)

我认为你需要添加

ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
  :domain             => "my-mail-server-domain.com",
  :address            => "mail.my-mail-server-domain.com",
  :port               => 25
  :authentication => :login ,
  :user_name          => 'myusername',
  :password           => 'mypassword',
}

ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.raise_delivery_errors = true
ActionMailer::Base.default_charset = "utf-8"
ActionMailer::Base.default_content_type = "text/html"

或尝试更改您的端口。通常端口25/26被阻止发送电子邮件,并且一些电子邮件提供商拒绝从端口25接收使用localhost smtp的电子邮件。 或者也许您的互联网服务提供商阻止端口25。 如果它仍然不起作用,你可以在这里写错误。