Pascal (Lazarus/Delphi)
Pascal (Lazarus/Delphi)
Clear the SMTP Session Log
See more SMTP Examples
Demonstrates the Chilkat MailMan.ClearSmtpSessionLog method, which clears the current contents of the SmtpSessionLog property. This example opens an SMTP connection (which populates the log) and then clears it.
Background: Like its POP3 counterpart, the
SmtpSessionLog records the raw client/server dialog — the EHLO, AUTH, MAIL FROM, RCPT TO, and DATA exchanges — which is the first thing to inspect when a send fails. Clearing it between sends keeps the captured log focused on the operation you care about rather than the entire history of a reused MailMan object.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.ClearSmtpSessionLog method, which clears the current contents of
// the SmtpSessionLog property.
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';
// Perform an SMTP operation, which populates the session log.
success := mailman.OpenSmtpConnection();
if (success = False) then
begin
WriteLn(mailman.LastErrorText);
Exit;
end;
// Clear the SMTP session log (for example, before the next operation).
mailman.ClearSmtpSessionLog();
success := mailman.CloseSmtpConnection();
if (success = False) then
begin
WriteLn(mailman.LastErrorText);
Exit;
end;
WriteLn('SMTP session log cleared.');
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.