Skip to content

monde-sistemas/delphi-aws-ses

Repository files navigation

delphi-aws-ses

Amazon Simple Email Service (AWS SES) library for Delphi applications.

Using

If you call the class method TAmazonEmailService.SendMail the library will look for the following environment variables: AWS_REGION, AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.

var
  EmailMessage: TEmailMessage;
begin
  EmailMessage.Recipients := TArray<string>.Create('[email protected]', '[email protected]');
  EmailMessage.FromName := 'John Doe'
  EmailMessage.FromAddress := '[email protected]';
  EmailMessage.Subject := 'This is the subject line with HTML.';
  EmailMessage.Body := 'Hello. I hope you are having a good day.';

  TAmazonEmailService.SendMail(EmailMessage);
end;

You may also manually instantiate the class and pass parameters to the constructor method:

var
  AmazonEmailService: TAmazonEmailService;
begin
  // ...
  AmazonEmailService := TAmazonEmailService.Create(AWS_REGION, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY);
  try
    AmazonEmailService.Send(EmailMessage);    
  finally
    AmazonEmailService.Free;
  end;
  

Body Type

Declaration: TBodyType = (btHTML, btText);

The email body can be sent in the following formats:

  • HTML - If the recipient's email client can interpret HTML, the body can include formatted text and hyperlinks
  • Plain text - If the recipient's email client is text-based, the body must not contain any nonprintable characters.

By default, the email will have HTML-enabled. To use text-based email will need you to set the EmailBody parameter values to btText.

Response Info

It's also possible to get the response information, setting as a parameter to the SendMail method a variable of type TCloudResponseInfo.

var
  ResponseInfo: TCloudResponseInfo;
begin
  // ...
  TAmazonEmailService.SendMail(EmailMessage, ResponseInfo);
  // ...

For example, if the email was sent successfully will be returned:

Response.StatusCode = 200
Response.StatusMessage = 'HTTP/1.1 200 OK'

Executing the tests

You need DUnitX do run the tests.

  • Clone the DUnitX repository locally
  • Define a DUNITX environment variable, pointing to the DUnitX clone directory.

Contributing

If you got something that's worth including into the project please submit a Pull Request or open an issue for further discussion.

License

This software is open source, licensed under the The MIT License (MIT). See LICENSE for details.

About

Delphi client for Amazon Simple Email Service (AWS SES)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages