Sample code for 30+ languages & platforms
Java

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

Chilkat2 Java
import com.chilkatsoft.chilkat2.ChilkatException;
import com.chilkatsoft.chilkat2.Email;
import com.chilkatsoft.chilkat2.MailMan;
import com.chilkatsoft.chilkat2.StringArray;

public class ChilkatExample {

    public static void main(String[] args) {
        // This example requires the Chilkat API to have been previously unlocked.
        // See Global Unlock Sample for sample code.

        MailMan mailman = new MailMan();

        // SMTP connection settings...
        mailman.setSmtpHost("smtp.example.com");
        mailman.setSmtpUsername("MY_SMTP_USERNAME");
        mailman.setSmtpPassword("MY_SMTP_PASSWORD");
        mailman.setSmtpSsl(true);
        mailman.setSmtpPort(465);

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

        email.setSubject("This is a test");
        email.setBody("This is a test");
        email.setFrom("myemail@example.com");
        email.addTo("person1", "person1@example.com");
        email.addTo("person2", "person2@example.com");
        email.addTo("person3", "person3@example.com");
        // The SMTP server smtp.example.com won't know anything about an email address @somewhere_else.com
        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.)
        StringArray badAddrs = new StringArray();
        try {
            mailman.verifyRecips(email, badAddrs);
        } catch (ChilkatException e) {
            System.out.println(e.getLastErrorText());
            return;
        }

        int i = 0;
        while (i < badAddrs.getCount()) {
            System.out.println(badAddrs.getString(i));
            i = i + 1;
        }

        System.out.println("done.");
    }
}