Skip to content

Lightweight, minimalist SMTP framework to send email messages in Delphi

License

Notifications You must be signed in to change notification settings

willisnou/Mailer4D

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


Mailer4D is a minimalist Delphi framework to configure a SMTP client and send email messages.
Also natively supports inline (base64) images for html messages.

Requisites

[Required] For SSL/TLS support libeay32.dll and ssleay32.dll is required, check out OpenSSL folder.

Instalation

[Optional] Boss instalation:

boss install github.com/willisnou/Mailer4D

[Manual] For manual installation add the ../Mailer4D/src directory on library path in Tools > Options > Language > Delphi > Library > Library Path or add the files manually to the project in Project > Add to Project... menu.

Getting started

uses Mailer4D.Mailer;

Sending an email message

var
  Mailer: IMailer;

begin
  Mailer:= TMailer.New;

  Mailer.
    .Host('smtp.host.com')
    .Port(587)
    .Username('username@example.com')
    .Password('user_password')
    .TLS(True)
    .Auth(True)
    .From('from@example.com', 'from name')
    .AddRecipient('recipient@example.com')
    .AddCC('cc@example.com')
    .AddBCC('cco@example.com')
    .ReceiptRecipient(False)
    .Subject('email subject')
    .AddBody('email body part', 'message part content-type')
    .AddAttachment('..\.\attachment.txt')
.Send;
end;

Sending an asynchronous email message

Define a callback of TProc<Boolean>:

procedure SentStatusCallback(ASent: Boolean);
begin
// TODO
end;

And then use SendAsynch method with the callback as parameter.

var
  Mailer: IMailer;

begin
  Mailer:= TMailer.New;

  Mailer.
    .Host('smtp.host.com')
    .Port(587)
    .Username('username@example.com')
    .Password('user_password')
    .TLS(True)
    .Auth(True)
    .From('from@example.com', 'from name')
    .AddRecipient('recipient@example.com')
    .AddCC('cc@example.com')
    .AddBCC('cco@example.com')
    .ReceiptRecipient(False)
    .Subject('email subject')
    .AddBody('email body part', 'message part content-type')
    .AddAttachment('..\.\attachment.txt')
.SendAsynch(SentStatusCallback);
end;

Sample code

Check out the sample code available with a simple user case.


Issues, questions or suggestions are apreciated.

About

Lightweight, minimalist SMTP framework to send email messages in Delphi

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages