Send email message
Free Pascal users have some options when sending email. Some library such as Indy has TIdSMTP which connect directly to SMTP server. As alternative, Fano Framework offers a way to send email by using sendmail binary.
To abstract away mail sender implementation,
IMailer interface is provided. It is a contract for any class having capability to send email.
Sending email with sendmail
var amailer : IMailer; ... amailer := container['mailer'] as IMailer; amailer.recipient := 'firstname.lastname@example.org'; amailer.sender := 'email@example.com'; amailer.subject := 'Hello'; amailer.body := 'Hello world'; amailer.send();
Setting up ssmtp library
To install ssmtp in Debian-based distribution,
$ sudo apt install ssmtp
$ sudo yum install ssmtp
/etc/ssmtp/ssmtp.conf and add following lines,
mailhub=smtp.yourownserver.com:25 AuthUser=YourUsername AuthPass=YourOWnSecretPassword FromLineOverride=YES
AuthPass with your own value. If you do not setup dedicated SMTP server, you can use external SMTP server such as gmail or mailtrap, or MailHog. Both mailtrap and MailHog is fake SMTP server which helps sending test email without fear of becoming email spammer during development.