Sample code for 30+ languages & platforms
PowerBuilder

Verify Email Recipients

A way to possibly determine valid/invalid email addresses. I would recommend being very careful about doing this because your IP address may be flagged as a potential spammer by the mail server (because you are probing for valid/invalid email addresses). This Chilkat functionality existed for many years, before this kind of activity became a problem. The functionality remains only because it is useful for some to test with their own SMTP servers.

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Mailman
oleobject loo_Email
oleobject loo_BadAddrs
integer i

li_Success = 0

// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

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

// SMTP connection settings...
loo_Mailman.SmtpHost = "smtp.example.com"
loo_Mailman.SmtpUsername = "MY_SMTP_USERNAME"
loo_Mailman.SmtpPassword = "MY_SMTP_PASSWORD"
loo_Mailman.SmtpSsl = 1
loo_Mailman.SmtpPort = 465

// Create a new email object
loo_Email = create oleobject
li_rc = loo_Email.ConnectToNewObject("Chilkat.Email")

loo_Email.Subject = "This is a test"
loo_Email.Body = "This is a test"
loo_Email.From = "myemail@example.com"
li_Success = loo_Email.AddTo("person1","person1@example.com")
li_Success = loo_Email.AddTo("person2","person2@example.com")
li_Success = loo_Email.AddTo("person3","person3@example.com")
// The SMTP server smtp.example.com won't know anything about an email address @somewhere_else.com
li_Success = loo_Email.AddTo("person3","person4@somewhere_else.com")
// ...

// Verify recipients.
// **** See the warning about using this API method in the description above.
// (An SMTP server only knows valid email address for its own domain.  For example,
// smtp.example.com *may* only know if person1@example.com is valid or invalid, but does
// not know anything about the validity of email addresses having other domains.)
loo_BadAddrs = create oleobject
li_rc = loo_BadAddrs.ConnectToNewObject("Chilkat.StringArray")

li_Success = loo_Mailman.VerifyRecips(loo_Email,loo_BadAddrs)
if li_Success <> 1 then
    Write-Debug loo_Mailman.LastErrorText
    destroy loo_Mailman
    destroy loo_Email
    destroy loo_BadAddrs
    return
end if

i = 0
do while i < loo_BadAddrs.Count
    Write-Debug loo_BadAddrs.GetString(i)
    i = i + 1
loop

Write-Debug "done."


destroy loo_Mailman
destroy loo_Email
destroy loo_BadAddrs