Sample code for 30+ languages & platforms
Zig

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

Zig
const std = @import("std");
const chilkat = @import("chilkat");

pub fn main(init: std.process.Init) !void {
    const alloc = init.arena.allocator();

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

    const mailman = try chilkat.MailMan.init();
    defer mailman.deinit();

    // 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
    const email = try chilkat.Email.init();
    defer email.deinit();

    email.setSubject("This is a test");
    email.setBody("This is a test");
    email.setFrom("myemail@example.com");
    try email.addTo("person1", "person1@example.com");
    try email.addTo("person2", "person2@example.com");
    try email.addTo("person3", "person3@example.com");
    // The SMTP server smtp.example.com won't know anything about an email address @somewhere_else.com
    try 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.)
    const bad_addrs = try chilkat.StringArray.init();
    defer bad_addrs.deinit();
    mailman.verifyRecips(email, bad_addrs) catch {
        std.debug.print("{s}\n", .{try mailman.getLastErrorText(alloc)});
        return;
    };

    var i: i32 = 0;
    while (i < bad_addrs.getCount()) {
        std.debug.print("{s}\n", .{try bad_addrs.getString(alloc, i)});
        i = i + 1;
    }

    std.debug.print("done.\n", .{});
}