Sample code for 30+ languages & platforms
Unicode C

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 Unicode C Downloads

Unicode C
#include <C_CkMailManW.h>
#include <C_CkEmailW.h>
#include <C_CkStringArrayW.h>

void ChilkatSample(void)
    {
    BOOL success;
    HCkMailManW mailman;
    HCkEmailW email;
    HCkStringArrayW badAddrs;
    int i;

    success = FALSE;

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

    mailman = CkMailManW_Create();

    //  SMTP connection settings...
    CkMailManW_putSmtpHost(mailman,L"smtp.example.com");
    CkMailManW_putSmtpUsername(mailman,L"MY_SMTP_USERNAME");
    CkMailManW_putSmtpPassword(mailman,L"MY_SMTP_PASSWORD");
    CkMailManW_putSmtpSsl(mailman,TRUE);
    CkMailManW_putSmtpPort(mailman,465);

    //  Create a new email object
    email = CkEmailW_Create();

    CkEmailW_putSubject(email,L"This is a test");
    CkEmailW_putBody(email,L"This is a test");
    CkEmailW_putFrom(email,L"myemail@example.com");
    success = CkEmailW_AddTo(email,L"person1",L"person1@example.com");
    success = CkEmailW_AddTo(email,L"person2",L"person2@example.com");
    success = CkEmailW_AddTo(email,L"person3",L"person3@example.com");
    //  The SMTP server smtp.example.com won't know anything about an email address @somewhere_else.com
    success = CkEmailW_AddTo(email,L"person3",L"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.)
    badAddrs = CkStringArrayW_Create();
    success = CkMailManW_VerifyRecips(mailman,email,badAddrs);
    if (success != TRUE) {
        wprintf(L"%s\n",CkMailManW_lastErrorText(mailman));
        CkMailManW_Dispose(mailman);
        CkEmailW_Dispose(email);
        CkStringArrayW_Dispose(badAddrs);
        return;
    }

    i = 0;
    while (i < CkStringArrayW_getCount(badAddrs)) {
        wprintf(L"%s\n",CkStringArrayW_getString(badAddrs,i));
        i = i + 1;
    }

    wprintf(L"done.\n");


    CkMailManW_Dispose(mailman);
    CkEmailW_Dispose(email);
    CkStringArrayW_Dispose(badAddrs);

    }