Skip to content

Sending emails through Exchange Online using SMTP with OAuth2 can be a robust, secure alternative to traditional username/password authentication.

License

Notifications You must be signed in to change notification settings

michaelJustin/delphi-smtp-with-oauth2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 

Repository files navigation

GitHub issues GitHub forks GitHub top language GitHub stars

Secure Delphi SMTP With OAuth2

Requirements for FPCUnit test project

  • Lazarus IDE
  • Add required package for FPCUnit to the project
  • 64 Bit OpenSSL DLLs from Indy
  • Indy Sockets

Configuration

  • Add tenant id, client id and client secret in unit oauth2tokenprovider

const
TokenEndpoint = 'https://login.microsoftonline.com/{tenant}/oauth2/v2.0/token';
ClientID = '{client-id}';
ClientSecret = '{client-secret}';

  • Set recipient address and name in unit smtpoauth2client

AddressItem := IdMessage.Recipients.Add;
AddressItem.Address := 'recipient@example.com';
AddressItem.Name := 'Recipient';

  • Set authorized user and password (the auth token) in smtpoauth2client

UserPass := TIdUserPassProvider.Create(IdSMTP);
UserPass.Username := 'user@example.com';
UserPass.Password := OAuth2Token;

About

Sending emails through Exchange Online using SMTP with OAuth2 can be a robust, secure alternative to traditional username/password authentication.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published

Languages