经典ASP,在Windows Server 2008上发送电子邮件 - 错误'8004020f'

4
我正在尝试在Windows Server 2008 R2、IIS 7.5上使用经典ASP发送电子邮件(我被困在旧的应用程序中,所以我必须在这里使用经典ASP)。我猜很多事情从win server 2003到2008都有所改变。我正在使用以下代码,但是我遇到了这个错误(顺便说一句,错误消息非常“有信息量”):
错误 '8004020f' /poo.asp, line 32
以下是代码:
<!-- 
    METADATA 
    TYPE="typelib" 
    UUID="CD000000-8B95-11D1-82DB-00C04FB1625D"  
    NAME="CDO for Windows 2000 Library" 
-->  
<%  

    'Declare variables 
    Dim sch, cdoConfig, cdoMessage
    sch = "http://schemas.microsoft.com/cdo/configuration/" 

    Set cdoConfig = CreateObject("CDO.Configuration")  

    With cdoConfig.Fields  
        .Item(cdoSendUsingMethod) = cdoSendUsingPort  
        .Item(cdoSMTPServer) = "mail.example.com"
        'Set SMTP port which is 25 by default 
        .Item(sch & "smtpserverport") = 587 
        .Update  
    End With 

    Set cdoMessage = CreateObject("CDO.Message")  

    With cdoMessage 
        Set .Configuration = cdoConfig 
        .From = "info@example.com" 
        .To = "me@example2.com" 
        .Subject = "Sample CDO Message" 
        .TextBody = "This is a test for CDO.message" 
        .Send 
    End With 

    Set cdoMessage = Nothing  
    Set cdoConfig = Nothing  

Response.write "<HTML><head><title>A message has been sent.</title></head><body>A message has been sent.</body></HTML>"

%>

此外,我刚刚从http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=1004下载并安装了Microsoft Exchange Server MAPI Client and Collaboration Data Objects 1.2.1,但没有改变任何东西。 注意:如果本地主机可以工作,则可以发送电子邮件。
1个回答

4
你可能会遇到以下错误:

error '8004020f' 此订阅的事件类位于无效分区中

这个错误信息来自cdosys.h,与任何类型的“分区”都没有关系-它实际上被包含在其他错误消息中。该错误代码实际上归因于以下原因:
CONST LONG CDO_E_RECIPIENTS_REJECTED = 0x8004020FL

这意味着邮件由于某些原因被服务器拒绝。以下是您可以尝试缓解问题的一些方法:

  1. Make sure the SMTP server allows anonymous (non-authenticated) relaying. If your SMTP requires outgoing authentication, see Article #2026.

  2. Check if the problem is specific to the domain name(s) used in the e-mail addresses of the recipients. For example, some users have complained that they can send to users on their own domain only; others have said that they can send to any domain except their own (see Article #2511 for some potential causes and solutions).

  3. It may be simply that the e-mail address is being rejected, but other configuration settings on the SMTP server are preventing the true error message from being relayed propely back to the ASP script ... so verify that the address is valid.

  4. If you have a proxy or firewall, make sure the web server is set up to correctly pass through it, that the SMTP server knows about it, and that the proxy allows access to port 25.

  5. Try using a SendUsing value of 1 (pickup) instead of 2 (port). E.g. the following line:

    .Item(cdoSendUsingMethod) = cdoSendUsingPort
    
变成
.Item(cdoSendUsingMethod) = cdoSendUsingPickup

http://classicasp.aspfaq.com/email/why-does-cdo-message-give-me-8004020f-errors.html


3
好的,您只需复制并粘贴我已经阅读过的文章即可。 - tugberk
我正在使用ASP.NET System.Net类在同一服务器上轻松发送电子邮件。您认为我需要指定密码和用户名吗? - tugberk
2
您正在尝试发送电子邮件的服务器拒绝电子邮件收件人。如果在 CDO 外部工作,请尝试使用 localhost 作为 SMTP 服务器。 - ThatGuyInIT
另外,为什么您要使用端口587?如果使用端口25会起作用吗? - ThatGuyInIT
在土耳其,我们需要使用端口587。我不确定为什么,但是几年前土耳其的所有网络提供商都从25更改为587。 - tugberk
1
谢谢Sean,把它改成localhost就是魔法 :) - tugberk

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接