VBScript
VBScript
Authenticate with the SMTP Server
See more SMTP Examples
Demonstrates the Chilkat MailMan.SmtpAuthenticate method, which authenticates with the SMTP server using the current SMTP property settings, such as SmtpUsername and SmtpPassword. It is typically called after SmtpConnect. This example connects and then authenticates.
Background: SMTP authentication is a separate step from connecting: after the
EHLO handshake, the client proves its identity via the AUTH command using a mechanism the server offers (LOGIN, PLAIN, CRAM-MD5, XOAUTH2, etc.). Splitting connect and authenticate into explicit calls lets you pinpoint exactly which step fails — and hold an authenticated connection open to send many messages efficiently.Chilkat VBScript Downloads
Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
'Create a Unicode (utf-16) output text file.
Set outFile = fso.CreateTextFile("output.txt", True, True)
success = 0
' Demonstrates the MailMan.SmtpAuthenticate method, which authenticates with the SMTP server
' using the current SMTP property settings (such as SmtpUsername and SmtpPassword). It is
' typically called after SmtpConnect.
set mailman = CreateObject("Chilkat.MailMan")
' Configure the SMTP server connection.
mailman.SmtpHost = "smtp.example.com"
mailman.SmtpPort = 465
mailman.SmtpSsl = 1
mailman.SmtpUsername = "user@example.com"
mailman.SmtpPassword = "myPassword"
' Connect first, then authenticate.
success = mailman.SmtpConnect()
If (success = 0) Then
outFile.WriteLine(mailman.LastErrorText)
WScript.Quit
End If
success = mailman.SmtpAuthenticate()
If (success = 0) Then
outFile.WriteLine(mailman.LastErrorText)
WScript.Quit
End If
outFile.WriteLine("Authenticated with the SMTP server.")
outFile.Close