Sample code for 30+ languages & platforms
Lazarus Pascal Requires Chilkat v11.0.0+

Send one message with two blind copies

See more Email Object Examples

Set NoBccHeader before adding blind-copy addresses. SendEmail then includes those recipients in the SMTP envelope and omits their addresses from the message headers sent to the relay. Replace the example account and addresses before running this SMTP submission.

Chilkat Lazarus Pascal Downloads

Lazarus Pascal
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.Email,
  Chilkat.MailMan;

// ---------------------------------------------------------------------------

procedure RunDemo;
var
  success: Boolean;
  email: TEmail;
  mail: TMailMan;

begin
  success := False;

  //  Assumes Chilkat is unlocked. See Global Unlock Sample.

  email := TEmail.Create;
  email.From := 'Workshop team <events@example.com>';
  success := email.AddTo('Alex Rivera','alex@example.net');
  if (success <> True) then
    begin
      WriteLn(email.LastErrorText);
      Exit;
    end;
  email.Subject := 'Workshop registration';
  email.Body := 'Registration is confirmed.';
  //  Set this before AddBcc so the submitted MIME omits the Bcc header.
  email.UncommonOptions := 'NoBccHeader';
  success := email.AddBcc('Archive','archive@example.com');
  if (success <> True) then
    begin
      WriteLn(email.LastErrorText);
      Exit;
    end;
  success := email.AddBcc('Event records','records@example.com');
  if (success <> True) then
    begin
      WriteLn(email.LastErrorText);
      Exit;
    end;
  mail := TMailMan.Create;
  mail.SmtpHost := 'smtp.example.com';
  mail.SmtpPort := 465;
  mail.SmtpSsl := True;
  mail.RequireSslCertVerify := True;
  mail.SmtpUsername := 'SMTP_USERNAME';
  mail.SmtpPassword := 'SMTP_PASSWORD';
  success := mail.SendEmail(email);
  if (success <> True) then
    begin
      WriteLn(mail.LastErrorText);
      Exit;
    end;
  WriteLn('SMTP relay accepted the submission.');
  success := mail.CloseSmtpConnection();
  if (success <> True) then
    begin
      WriteLn('The SMTP session did not close cleanly.');
    end;


  email.Free;
  mail.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.