Pascal (Lazarus/Delphi)
Pascal (Lazarus/Delphi)
Check if the SMTP Server Supports DSN
See more SMTP Examples
Demonstrates the Chilkat MailMan.IsSmtpDsnCapable method, which contacts the SMTP server and determines whether it supports the DSN (Delivery Status Notification) extension defined by RFC 3461. This example configures the SMTP connection and reports whether DSN is available.
Background: DSN lets a sender request a delivery receipt — asking the mail system to report back on success, failure, or delay for each recipient. Not every server offers it, so
IsSmtpDsnCapable probes the server's advertised EHLO capabilities first. Checking before relying on DSN-related settings avoids surprises when a server silently ignores a receipt request it does not support.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
mailman: TMailMan;
dsnCapable: Boolean;
begin
// Demonstrates the MailMan.IsSmtpDsnCapable method, which contacts the SMTP server and
// determines whether it supports the DSN (Delivery Status Notification) extension defined
// by RFC 3461.
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';
// Check whether the server supports DSN.
dsnCapable := mailman.IsSmtpDsnCapable();
if (dsnCapable = True) then
begin
WriteLn('The SMTP server supports DSN.');
end
else
begin
WriteLn('The SMTP server does not support DSN.');
end;
// Note: Explicitly connecting/authenticating is optional. Chilkat MailMan automatically
// connects and authenticates -- using the property settings above -- whenever a server
// operation requires it. Calling the explicit connect/authenticate methods can still be
// helpful to determine whether a failure occurs while connecting or while authenticating.
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.