Delphi DLL
Delphi DLL
Authenticate with the SMTP Server
See more SMTP Examples
Demonstrates the Chilkat MailMan.SmtpAuthenticate method, which authenticates with the SMTP server using the current SMTP property settings, such as SmtpUsername and SmtpPassword. It is typically called after SmtpConnect. This example connects and then authenticates.
Background: SMTP authentication is a separate step from connecting: after the
EHLO handshake, the client proves its identity via the AUTH command using a mechanism the server offers (LOGIN, PLAIN, CRAM-MD5, XOAUTH2, etc.). Splitting connect and authenticate into explicit calls lets you pinpoint exactly which step fails — and hold an authenticated connection open to send many messages efficiently.Chilkat Delphi DLL Downloads
var
success: Boolean;
mailman: HCkMailMan;
begin
success := False;
// Demonstrates the MailMan.SmtpAuthenticate method, which authenticates with the SMTP server
// using the current SMTP property settings (such as SmtpUsername and SmtpPassword). It is
// typically called after SmtpConnect.
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');
// Connect first, then authenticate.
success := CkMailMan_SmtpConnect(mailman);
if (success = False) then
begin
Memo1.Lines.Add(CkMailMan__lastErrorText(mailman));
Exit;
end;
success := CkMailMan_SmtpAuthenticate(mailman);
if (success = False) then
begin
Memo1.Lines.Add(CkMailMan__lastErrorText(mailman));
Exit;
end;
Memo1.Lines.Add('Authenticated with the SMTP server.');
CkMailMan_Dispose(mailman);