Pascal (Lazarus/Delphi)
Pascal (Lazarus/Delphi)
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 Pascal (Lazarus/Delphi) Downloads
program ChilkatDemo;
// Demonstrates using the Chilkat Pascal wrapper via the C bridge DLL.
// Builds as a console application under Lazarus (FPC) or Delphi.
{$IFDEF FPC}
{$MODE DELPHI}
{$ENDIF}
{$APPTYPE CONSOLE}
uses
{$IFDEF UNIX}
cthreads,
{$ENDIF}
SysUtils,
CkDllLoader,
Chilkat.MailMan;
// ---------------------------------------------------------------------------
procedure RunDemo;
var
success: Boolean;
mailman: TMailMan;
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 := TMailMan.Create;
// Configure the SMTP server connection.
mailman.SmtpHost := 'smtp.example.com';
mailman.SmtpPort := 465;
mailman.SmtpSsl := True;
mailman.SmtpUsername := 'user@example.com';
mailman.SmtpPassword := 'myPassword';
// Open the connection.
success := mailman.OpenSmtpConnection();
if (success = False) then
begin
WriteLn(mailman.LastErrorText);
Exit;
end;
// Reset the current SMTP mail transaction.
success := mailman.SmtpReset();
if (success = False) then
begin
WriteLn(mailman.LastErrorText);
Exit;
end;
success := mailman.CloseSmtpConnection();
if (success = False) then
begin
WriteLn(mailman.LastErrorText);
Exit;
end;
WriteLn('Sent SMTP RSET.');
mailman.Free;
end;
// ---------------------------------------------------------------------------
begin
try
RunDemo;
except
on E: Exception do
WriteLn('Unhandled exception: ', E.ClassName, ': ', E.Message);
end;
WriteLn;
{$IFDEF MSWINDOWS}
WriteLn('Press Enter to exit...');
ReadLn;
{$ENDIF}
end.