DataFlex
DataFlex
Verify SMTP Login (Connect and Authenticate)
See more SMTP Examples
Demonstrates the Chilkat MailMan.VerifySmtpLogin method, which tests whether Chilkat can connect to the configured SMTP server and successfully authenticate using the current SMTP authentication settings. This example configures the SMTP host and credentials and verifies login.
Background: This goes one step further than
VerifySmtpConnection: after reaching the server it also performs the AUTH exchange with your username and password (or OAuth2 token). It's the ideal preflight check when validating credentials or diagnosing "why won't my mail send?" — a false result after a good connection points squarely at bad credentials or an unsupported auth method rather than a network problem.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoMailman
Boolean iLoggedIn
Move False To iSuccess
// Demonstrates the MailMan.VerifySmtpLogin method, which tests whether Chilkat can connect
// to the configured SMTP server and successfully authenticate using the current SMTP
// authentication settings.
Get Create (RefClass(cComChilkatMailMan)) To hoMailman
If (Not(IsComObjectCreated(hoMailman))) Begin
Send CreateComObject of hoMailman
End
// Configure the SMTP server connection.
Set ComSmtpHost Of hoMailman To "smtp.example.com"
Set ComSmtpPort Of hoMailman To 465
Set ComSmtpSsl Of hoMailman To True
Set ComSmtpUsername Of hoMailman To "user@example.com"
Set ComSmtpPassword Of hoMailman To "myPassword"
// Test both connectivity and authentication.
Get ComVerifySmtpLogin Of hoMailman To iLoggedIn
If (iLoggedIn = True) Begin
Showln "Successfully connected and authenticated with the SMTP server."
End
Else Begin
Showln "SMTP connect or login failed."
End
End_Procedure