【问题标题】:How to send email with SMTP service with IIS8 and Classic ASP?如何使用 IIS8 和 Classic ASP 使用 SMTP 服务发送电子邮件?
【发布时间】:2015-02-25 20:44:31
【问题描述】:

我正在尝试使用经典 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

【问题讨论】:

标签: email asp-classic smtp cdo.message iis-8.5


【解决方案1】:

从您的代码看来,您似乎是在使用 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

猜你喜欢
  • 2013-02-03
  • 1970-01-01
  • 2012-06-10
  • 2016-09-07
  • 1970-01-01
  • 1970-01-01
  • 2021-10-01
  • 2015-06-19
相关资源
最近更新 更多