Sample code for 30+ languages & platforms
Xbase++

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 Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oMailman

nSuccess := 0

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

oMailman := CreateObject("Chilkat.MailMan")

//  Configure the SMTP server connection.
oMailman:SmtpHost := "smtp.example.com"
oMailman:SmtpPort := 465
oMailman:SmtpSsl := 1
oMailman:SmtpUsername := "user@example.com"
oMailman:SmtpPassword := "myPassword"

//  Open the connection.

nSuccess := oMailman:OpenSmtpConnection()
IF (nSuccess == 0)
    ? oMailman:LastErrorText
    oMailman:destroy()
    RETURN
ENDIF

//  Reset the current SMTP mail transaction.
nSuccess := oMailman:SmtpReset()
IF (nSuccess == 0)
    ? oMailman:LastErrorText
    oMailman:destroy()
    RETURN
ENDIF

nSuccess := oMailman:CloseSmtpConnection()
IF (nSuccess == 0)
    ? oMailman:LastErrorText
    oMailman:destroy()
    RETURN
ENDIF

? "Sent SMTP RSET."

oMailman:destroy()