Sample code for 30+ languages & platforms
PowerBuilder

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 PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Mailman
integer li_LoggedIn

li_Success = 0

//  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.

loo_Mailman = create oleobject
li_rc = loo_Mailman.ConnectToNewObject("Chilkat.MailMan")
if li_rc < 0 then
    destroy loo_Mailman
    MessageBox("Error","Connecting to COM object failed")
    return
end if

//  Configure the SMTP server connection.
loo_Mailman.SmtpHost = "smtp.example.com"
loo_Mailman.SmtpPort = 465
loo_Mailman.SmtpSsl = 1
loo_Mailman.SmtpUsername = "user@example.com"
loo_Mailman.SmtpPassword = "myPassword"

//  Test both connectivity and authentication.
li_LoggedIn = loo_Mailman.VerifySmtpLogin()

if li_LoggedIn = 1 then
    Write-Debug "Successfully connected and authenticated with the SMTP server."
else
    Write-Debug "SMTP connect or login failed."
end if



destroy loo_Mailman