Sample code for 30+ languages & platforms
Delphi DLL

Verify SMTP Login (Connect and Authenticate)

See more SMTP Examples

Demonstrates the Chilkat MailMan.VerifySmtpLogin method, which tests whether Chilkat can connect to the configured SMTP server and successfully authenticate using the current SMTP authentication settings. This example configures the SMTP host and credentials and verifies login.

Background: This goes one step further than VerifySmtpConnection: after reaching the server it also performs the AUTH exchange with your username and password (or OAuth2 token). It's the ideal preflight check when validating credentials or diagnosing "why won't my mail send?" — a false result after a good connection points squarely at bad credentials or an unsupported auth method rather than a network problem.

Chilkat Delphi DLL Downloads

Delphi DLL
var
success: Boolean;
mailman: HCkMailMan;
loggedIn: Boolean;

begin
success := False;

//  Demonstrates the MailMan.VerifySmtpLogin method, which tests whether Chilkat can connect
//  to the configured SMTP server and successfully authenticate using the current SMTP
//  authentication settings.

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');

//  Test both connectivity and authentication.
loggedIn := CkMailMan_VerifySmtpLogin(mailman);

if (loggedIn = True) then
  begin
    Memo1.Lines.Add('Successfully connected and authenticated with the SMTP server.');
  end
else
  begin
    Memo1.Lines.Add('SMTP connect or login failed.');
  end;

CkMailMan_Dispose(mailman);