109 lines
2.9 KiB
Markdown
109 lines
2.9 KiB
Markdown
# Correo
|
|
|
|
**Correo** is a .NET service designed for programmatically sending emails. It supports communication through two simultaneous channels:
|
|
|
|
- **HTTP (via REST API)**
|
|
- **Pub/Sub Messaging (via NATS)**
|
|
|
|
Correo can be integrated with various email mediators, offering flexible configuration options.
|
|
|
|
## Mediator Configuration
|
|
|
|
Correo supports multiple email mediators, configured using the following setting:
|
|
|
|
```json
|
|
"SmtpMediator": "SmtpClient" // Options: SmtpClient, SendGrid, Mailgun
|
|
```
|
|
|
|
## Supported Mediators
|
|
|
|
### SMTP Servers
|
|
Correo supports integration with standard SMTP email servers, including:
|
|
|
|
- **Local SMTP servers**
|
|
- **Gmail**
|
|
- **Yahoo**
|
|
|
|
SMTP integration is possible using either of two libraries: **.NET's built-in SMTP client** or **MailKit**. The configuration section in `appsettings.json` is as follows:
|
|
|
|
```json
|
|
"SmtpClient": {
|
|
"Package": "MailKit", // Options: .NET, MailKit
|
|
"Server": "smtp.gmail.com",
|
|
"Port": "587",
|
|
"UseAuthentication": true,
|
|
"Authentication": {
|
|
"UserName": "<account>@gmail.com",
|
|
"Domain": "",
|
|
"Password": "********"
|
|
},
|
|
"EnableSsl": true,
|
|
"TrustServer": false
|
|
}
|
|
```
|
|
|
|
### Transactional Email APIs
|
|
|
|
Correo also supports transactional email APIs for scalable email sending solutions:
|
|
|
|
#### **SendGrid**
|
|
[SendGrid](https://app.sendgrid.com/) is a cloud-based SMTP provider that simplifies email sending without managing servers. It provides an easy-to-use API and a free plan allowing up to 100 emails per day.
|
|
|
|
To configure SendGrid, generate an API key from the SendGrid platform and update `appsettings.json`:
|
|
|
|
```json
|
|
"SmtpMediator": "SendGrid",
|
|
"SendGrid": {
|
|
"ApiKey": "xxxxxxxxxxx"
|
|
}
|
|
```
|
|
|
|
#### **Mailgun**
|
|
[Mailgun](https://app.mailgun.com/) is an email automation service that offers transactional email APIs, with free and pay-as-you-go pricing options.
|
|
|
|
To configure Mailgun, generate an API key from Mailgun and specify the domain name in `appsettings.json`:
|
|
|
|
```json
|
|
"SmtpMediator": "Mailgun",
|
|
"Mailgun": {
|
|
"ApiKey": "xxxxxxxxxxx",
|
|
"Domain": "xxxxxxxxxxx"
|
|
}
|
|
```
|
|
|
|
## Logging
|
|
|
|
Correo uses **Serilog** for logging, which can be configured in `appsettings.json`. It supports logging to multiple destinations:
|
|
|
|
- **File-based logging**
|
|
- **PostgreSQL database logging**
|
|
- **Seq (structured log management)**
|
|
|
|
The logging configuration section:
|
|
|
|
```json
|
|
"Logs": {
|
|
"File": {
|
|
"Enabled": false,
|
|
"Path": "logs/log.txt"
|
|
},
|
|
"Postgres": {
|
|
"Enabled": false,
|
|
"Connection": "Host=<host>;Port=5432;User ID=<user>;Password=<password>;Database=<database>;"
|
|
},
|
|
"Seq": {
|
|
"Enabled": false,
|
|
"Url": "",
|
|
"ApiKey": ""
|
|
}
|
|
}
|
|
```
|
|
|
|
## Hosting
|
|
|
|
Correo is primarily tested in **Docker** environments, but as it is built on **.NET 8**, it is cross-platform and can likely be hosted in various environments, including **Linux, Windows, and Kubernetes clusters**.
|
|
|
|
---
|
|
|
|
For further details and updates, visit the project repository or documentation.
|