Zig
Zig
Send an SMTP RSET Command
See more SMTP Examples
Demonstrates the Chilkat MailMan.SmtpReset method, which sends an SMTP RSET command to the server. RSET resets the server-side state of the current mail transaction. This example opens a connection, sends RSET, and closes.
Background: During an SMTP session a message is built up across
MAIL FROM and RCPT TO commands. If you need to abandon that partially-specified transaction — say an error occurred midway — RSET clears it without dropping the connection, so the same authenticated session can start a fresh message. It's a lightweight way to recover in-session rather than reconnecting.Chilkat Zig Downloads
const std = @import("std");
const chilkat = @import("chilkat");
pub fn main(init: std.process.Init) !void {
const alloc = init.arena.allocator();
// Demonstrates the MailMan.SmtpReset method, which sends an SMTP RSET command to the server.
// RSET resets the server-side state of the current mail transaction.
const mailman = try chilkat.MailMan.init();
defer mailman.deinit();
// Configure the SMTP server connection.
mailman.setSmtpHost("smtp.example.com");
mailman.setSmtpPort(465);
mailman.setSmtpSsl(true);
mailman.setSmtpUsername("user@example.com");
mailman.setSmtpPassword("myPassword");
// Open the connection.
mailman.openSmtpConnection() catch {
std.debug.print("{s}\n", .{try mailman.getLastErrorText(alloc)});
return;
};
// Reset the current SMTP mail transaction.
mailman.smtpReset() catch {
std.debug.print("{s}\n", .{try mailman.getLastErrorText(alloc)});
return;
};
mailman.closeSmtpConnection() catch {
std.debug.print("{s}\n", .{try mailman.getLastErrorText(alloc)});
return;
};
std.debug.print("Sent SMTP RSET.\n", .{});
}