Sample code for 30+ languages & platforms
Lua

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

Lua
local chilkat = require("chilkat")

-- 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.

local mailman = chilkat.MailMan.new()

-- Configure the SMTP server connection.
mailman.smtp_host = "smtp.example.com"
mailman.smtp_port = 465
mailman.smtp_ssl = true
mailman.smtp_username = "user@example.com"
mailman.smtp_password = "myPassword"

-- Open the connection.

local success = mailman:open_smtp_connection()
if not success then
    print(mailman.last_error_text)
    return
end

-- Reset the current SMTP mail transaction.
success = mailman:smtp_reset()
if not success then
    print(mailman.last_error_text)
    return
end

success = mailman:close_smtp_connection()
if not success then
    print(mailman.last_error_text)
    return
end

print("Sent SMTP RSET.")