Tcl
Tcl
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 Tcl Downloads
load ./chilkat.dll
set 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 [new_CkMailMan]
# Configure the SMTP server connection.
CkMailMan_put_SmtpHost $mailman "smtp.example.com"
CkMailMan_put_SmtpPort $mailman 465
CkMailMan_put_SmtpSsl $mailman 1
CkMailMan_put_SmtpUsername $mailman "user@example.com"
CkMailMan_put_SmtpPassword $mailman "myPassword"
# Connect first, then authenticate.
set success [CkMailMan_SmtpConnect $mailman]
if {$success == 0} then {
puts [CkMailMan_lastErrorText $mailman]
delete_CkMailMan $mailman
exit
}
set success [CkMailMan_SmtpAuthenticate $mailman]
if {$success == 0} then {
puts [CkMailMan_lastErrorText $mailman]
delete_CkMailMan $mailman
exit
}
puts "Authenticated with the SMTP server."
delete_CkMailMan $mailman