2.9 KiB
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:
"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:
"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 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
:
"SmtpMediator": "SendGrid",
"SendGrid": {
"ApiKey": "xxxxxxxxxxx"
}
Mailgun
Mailgun 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
:
"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:
"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.