Sample code for 30+ languages & platforms
Zig

Send email using SSL (port 465).

Send email using SMTP SSL on port 465.

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.

    // The mailman object is used for sending and receiving email.
    const mailman = try chilkat.MailMan.init();
    defer mailman.deinit();

    // Set the SMTP server.
    mailman.setSmtpHost("smtp.att.yahoo.com");

    // Set SMTP login and password (if necessary)
    mailman.setSmtpUsername("myUsername@sbcglobal.net");
    mailman.setSmtpPassword("myPassword");

    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("Chilkat Support <support@chilkatsoft.com>");
    try email.addTo("Chilkat Admin", "admin@chilkatsoft.com");

    mailman.sendEmail(email) catch {
        std.debug.print("{s}\n", .{try mailman.getLastErrorText(alloc)});
        return;
    };

    mailman.closeSmtpConnection() catch {
        std.debug.print("Connection to SMTP server not closed cleanly.\n", .{});
    };

    std.debug.print("Mail Sent!\n", .{});
}