1

我正在尝试使用经典的 ASP 和 IIS 8.5 发送电子邮件,为此我在 IIS 中使用 SMTP 服务(无 SMTP 服务器)和来自 Gmail 的电子邮件帐户。

我测试页面时的错误消息是:

CDO.Message.1 错误“80040213”

Error de transporte en la conexión al servidor。

/anotala/prueba-Email.asp,线 38

我的 ASP 代码是:

Set objConfig = Server.CreateObject("CDO.Configuration")
Set Fields = objConfig.Fields

With Fields
 .Item(cdoSendUsingMethod)       = cdoSendUsingPort
 .Item(cdoSMTPServer)            = "smtp.gmail.com"

 .Item(cdoSMTPServerPort)        = 25
 '.Item(cdoSMTPConnectionTimeout) = 10
 .Item(cdoSMTPAuthenticate)      = cdoBasic
 .Item(cdoSendUserName)          = "emailaccount@gmail"
 .Item(cdoSendPassword)          = "pwd123"

 .Update
End With

Set objMessage = Server.CreateObject("CDO.Message")

Set objMessage.Configuration = objConfig

With objMessage
 .To       = "to@gmail.com"
 .From     = "from@gmail.com"                 
 .Subject  = "Prueba Nro. 1"
 .TextBody = "Este es el cuerpo de la prueba Nro. 1"
 .Send
End With

这是IIS的配置:

在此处输入图像描述

我想知道问题出在哪里以及如何解决?

http://www.w3schools.com/asp/asp_send_email.asp https://support.google.com/a/answer/176600?hl=es

4

1 回答 1

2

从您的代码看来,您似乎是在使用 IIS 配置在代码中设置 smtp 连接。我不相信您可以将 IIS 配置与 CDOSYS 一起使用(请参阅此处的答案:https ://stackoverflow.com/a/6489539/3915817 )。您已经在代码中正确设置了它,但是这一行

.Item(cdoSMTPServer)            = "smtp.gmail.com"

表示您正在使用 google 的 smtp 连接的仅 SSL 版本。这实际上很好,因为您可能希望无论如何加密您的用户名和密码,而不是以纯文本形式发送它们。不过,您需要告诉 CDOSYS 使用 SSL。您可以通过首先使用基于 Google API 的正确端口来做到这一点,因此我会将您的端口行更改为:

.Item(cdoSMTPServerPort)        = 465

然后您需要设置启用 SSL 添加另一个常量

Const cdoSendTLS = "http://schemas.microsoft.com/cdo/configuration/smtpusessl"

并将项目行添加到您的字段块中,如下所示

.Item(cdoSendTLS) = 1

资料来源:

http://www.saotn.org/authenticated-smtp-tlsscript-example-asp-php-aspnet-csharp-vbnet/#auth_smtp_tls_classic_asp

http://webcheatsheet.com/asp/sending_email_asp.php#remoteservergmail

于 2015-02-25T21:43:42.817 回答