Sample code for 30+ languages & platforms
Zig

Send a POP3 NOOP Command

See more POP3 Examples

Demonstrates the Chilkat MailMan.Pop3Noop method, which sends a POP3 NOOP command to the server. NOOP does nothing except elicit a positive response, which is useful for keeping a session alive or verifying the connection is still responsive. This example begins a POP3 session and sends a NOOP.

Background: NOOP ("no operation") is a standard keep-alive across many internet protocols. Servers often drop idle connections after a timeout; sending a periodic NOOP resets that timer so a long-running session stays open. It also serves as a cheap "are you still there?" probe — a successful reply confirms the socket and the authenticated session are still healthy.

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();

    // Demonstrates the MailMan.Pop3Noop method, which sends a POP3 NOOP command to the server.
    // NOOP does nothing except elicit a positive response, which is useful for keeping a
    // session alive or verifying the connection is still responsive.

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

    // Configure the POP3 server connection.
    mailman.setMailHost("pop.example.com");
    mailman.setMailPort(995);
    mailman.setPopSsl(true);
    mailman.setPopUsername("user@example.com");
    mailman.setPopPassword("myPassword");

    // Begin a POP3 session.

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

    // Send a NOOP to keep the session alive.
    mailman.pop3Noop() catch {
        std.debug.print("{s}\n", .{try mailman.getLastErrorText(alloc)});
        return;
    };

    std.debug.print("POP3 NOOP succeeded.\n", .{});
}