Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Classic ASP sending email with SMTP Authentication

We have inherited a classic ASP site from a design agency who just wanted us to do a search and replace to change SMTP hosts. No problem, we are a PHP shop but can turn our hands to most things.

On further investigation it was discovered that we need to authenticate with the new SMTP server.

A bit of googling lead us to believe that it is using ASPMail 4 and according to the docs it doesn't do authentication.

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

We just googled "SMTPsvg.Mailer" from this call:

Set Mailer = Server.CreateObject("SMTPsvg.Mailer")

Am I correct in my assumptions that the above is ASPMail 4, and the APSMAil doesn't do authentication?

What can I use to authenticate with a SMTP server if I need to replace Aspmail?

like image 505
johnwards Avatar asked Feb 17 '10 15:02

johnwards


1 Answers

As said, use 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

Docs about each field of the config object can be found here!

like image 103
Joost Moesker Avatar answered Sep 19 '22 00:09

Joost Moesker