经典ASP使用SMTP身份验证发送电子邮件

joh*_*rds 7 smtp asp-classic

我们从设计机构继承了一个经典的ASP网站,该网站只是希望我们进行搜索和替换以更改SMTP主机.没问题,我们是PHP商店,但可以把手转向大多数事情.

在进一步调查中发现我们需要使用新的SMTP服务器进行身份验证.

一些谷歌搜索引导我们相信它正在使用ASPMail 4并根据文档它不进行身份验证.

http://www.serverobjects.com/comp/Aspmail4.htm

我们只是用这个电话搜索了"SMTPsvg.Mailer":

Set Mailer = Server.CreateObject("SMTPsvg.Mailer")
Run Code Online (Sandbox Code Playgroud)

我在假设上面是ASPMail 4并且APSMAil不进行身份验证时是否正确?

如果我需要替换Aspmail,我可以用什么来验证SMTP服务器?

Joo*_*ker 20

如上所述,使用CDO.

set config = CreateObject("CDO.Configuration")
sch = "http://schemas.microsoft.com/cdo/configuration/"
with config.Fields
 .item(sch & "sendusing") = 2 ' cdoSendUsingPort
 .item(sch & "smtpserver") = application("smtpserver")
 .item(sch & "smtpserverport") = application("smtpserverport")
 .item(sch & "smtpauthenticate") = 1 'basic auth
 .item(sch & "sendusername") = application("sendusername")
 .item(sch & "sendpassword") = application("sendpassword")
 .update
end with

with CreateObject("CDO.Message")
  .configuration = config
  .to = ...
  .from = ...
  .subject = ....
  .HTMLBody = ....
  call .send()
end with
Run Code Online (Sandbox Code Playgroud)

有关配置对象的每个字段的文档可以在这里找到!