Sample code for 30+ languages & platforms
Delphi DLL

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 Delphi DLL Downloads

Delphi DLL
var
success: Boolean;
mailman: HCkMailMan;

begin
success := False;

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

mailman := CkMailMan_Create();

//  Configure the SMTP server connection.
CkMailMan_putSmtpHost(mailman,'smtp.example.com');
CkMailMan_putSmtpPort(mailman,465);
CkMailMan_putSmtpSsl(mailman,True);
CkMailMan_putSmtpUsername(mailman,'user@example.com');
CkMailMan_putSmtpPassword(mailman,'myPassword');

//  Open the connection.

success := CkMailMan_OpenSmtpConnection(mailman);
if (success = False) then
  begin
    Memo1.Lines.Add(CkMailMan__lastErrorText(mailman));
    Exit;
  end;

//  Reset the current SMTP mail transaction.
success := CkMailMan_SmtpReset(mailman);
if (success = False) then
  begin
    Memo1.Lines.Add(CkMailMan__lastErrorText(mailman));
    Exit;
  end;

success := CkMailMan_CloseSmtpConnection(mailman);
if (success = False) then
  begin
    Memo1.Lines.Add(CkMailMan__lastErrorText(mailman));
    Exit;
  end;

Memo1.Lines.Add('Sent SMTP RSET.');

CkMailMan_Dispose(mailman);