Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dliocode/sendemail
Function to send email for Delphi.
https://github.com/dliocode/sendemail
delphi email idsmtp indy log logger mail pascal sendemail smtp
Last synced: 4 days ago
JSON representation
Function to send email for Delphi.
- Host: GitHub
- URL: https://github.com/dliocode/sendemail
- Owner: dliocode
- Created: 2020-10-21T01:43:24.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2023-06-21T17:00:35.000Z (over 1 year ago)
- Last Synced: 2024-11-07T08:51:44.942Z (about 2 months ago)
- Topics: delphi, email, idsmtp, indy, log, logger, mail, pascal, sendemail, smtp
- Language: Pascal
- Homepage:
- Size: 4.97 MB
- Stars: 67
- Watchers: 9
- Forks: 29
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## SendEmail
Function to send email for Delphi.
Support: [email protected]
:fast_forward: Here is an example [Samples](https://github.com/dliocode/sendemail/tree/main/samples)
## :warning: Usage
### :green_book: Mode: Simple
```delphi
uses
SendEmail;begin
TSendEmail.New
.From('Email', 'Name')
.AddTo('Email', 'Name')
.AddReceiptRecipient('Email', 'Name') // Confirmation Read
.AddReplyTo('Email', 'Name') // Answer to
.AddCC('Email', 'Name')
.AddBCC('Email', 'Name')
.Priority(TPriority.mpNormal)
.Subject('My Text with SendEmail')
.Message('Message
', True) // True is Default = Text in HTML
.AddAttachment('')
.Host('[email protected]')
.Port(587)
.Auth(True)
.UserName('username')
.Password('password')
.SSL(False)
.TLS(False)
.Send(True); // True is Default = After sending it will be disconnected
end.
```### :orange_book: Mode: With logger
```delphi
uses
SendEmail;begin
TSendEmail.New
.OnLog(
procedure(ALog: string)
begin
Writeln(Format('%s ' + ALog, [FormatDateTime('dd/mm/yyyy hh:MM:ss', Now)]));
end,
TLogMode.lmLib) // Options: lmComponent, lmLib, lmAll, lmNone
.From('Email', 'Name')
.AddTo('Email', 'Name')
.AddReceiptRecipient('Email', 'Name') // Confirmation Read
.AddReplyTo('Email', 'Name') // Answer to
.AddCC('Email', 'Name')
.AddBCC('Email', 'Name')
.Priority(TPriority.mpNormal)
.Subject('My Text with SendEmail')
.Message('Message
', True) // True is Default = Text in HTML
.AddAttachment('')
.Host('[email protected]')
.Port(587)
.Auth(True)
.UserName('username')
.Password('password')
.SSL(False)
.TLS(False)
.Send(True); // True is Default = After sending it will be disconnected
end.
```### :closed_book: Mode: With progress bar
```delphi
uses
SendEmail;begin
TSendEmail.New
.OnWorkBegin(
procedure(ACountMax: Int64)
begin
ProgressBar.Max := ACountMax;
ProgressBar.Position := 0;
ProgressBar.Refresh;
end)
.OnWork(
procedure(ACount: Int64)
begin
ProgressBar.Position := ACount;
ProgressBar.Refresh;
end)
.OnWorkEnd(
procedure
begin
ProgressBar.Position := ProgressBar.Max;
ProgressBar.Refresh;
end)
.From('Email', 'Name')
.AddTo('Email', 'Name')
.AddReceiptRecipient('Email', 'Name') // Confirmation Read
.AddReplyTo('Email', 'Name') // Answer to
.AddCC('Email', 'Name')
.AddBCC('Email', 'Name')
.Priority(TPriority.mpNormal)
.Subject('My Text with SendEmail')
.Message('Message
', True) // True is Default = Text in HTML
.AddAttachment('')
.Host('[email protected]')
.Port(587)
.Auth(True)
.UserName('username')
.Password('password')
.SSL(False)
.TLS(False)
.Send(True); // True is Default = After sending it will be disconnected
end.
```### :notebook_with_decorative_cover: Send asynchronous mode
```delphi
uses
SendEmail;begin
TSendEmail.New
.From('Email', 'Name')
.AddTo('Email', 'Name')
.AddReceiptRecipient('Email', 'Name') // Confirmation Read
.AddReplyTo('Email', 'Name') // Answer to
.AddCC('Email', 'Name')
.AddBCC('Email', 'Name')
.Priority(TPriority.mpNormal)
.Subject('My Text with SendEmail')
.Message('Message
', True) // True is Default = Text in HTML
.AddAttachment('')
.Host('[email protected]')
.Port(587)
.Auth(True)
.UserName('username')
.Password('password')
.SSL(False)
.TLS(False)
.SendAsync(
procedure(AErro: Boolean; AMessageErro: string) // Informed callback to return
begin
if AErro then
ShowMessage(AMessageErro)
else
ShowMessage('Message sent!')
end, True); // True is Default = After sending it will be disconnected
end.
```## :satellite: Host SMTP
| **Name** | **Host** | **Port** | **Cryptography** | **Auth** |
| :---: | :---: | :---: | :---: | :---: |
| Gmail | smtp.gmail.com | 465 | SSL/TLS | Yes |
| Outlook or Office 365 | smtp.office365.com | 587 | TLS | Yes |
| Hotmail | smtp.live.com | 587 | TLS | Yes |
| Yahoo | smtp.mail.yahoo.com.br | 587 | TLS | Yes |
| SendGrid | smtp.sendgrid.net | 465 | TLS | Yes |
| LocalWeb | email-ssl.com.br | 465 | TLS | Yes |
| SparkPost | smtp.sparkpostmail.com | 587 | TLS | Yes |
| Elastic Email | smtp.elasticemail.com | 587 | None | Yes |
| Mail | smtp.mail.ru | 465 | SSL/TLS | Yes |