Modern .NET 9 mailing library with Razor template engine and multi-provider support. Send beautiful, dynamic emails with SMTP, SendGrid, or Mailgun.
Powerful email library designed for .NET developers who need flexible, template-driven email functionality with multiple provider options.
Create dynamic, beautiful HTML emails using familiar Razor syntax with strongly-typed models and full C# support.
Switch seamlessly between SMTP, SendGrid, and Mailgun with a unified API. No vendor lock-in.
Template caching, async/await throughout, and modern .NET 9 optimizations for blazing fast email generation and sending.
Sanquhar is named after the oldest operating post office in the world, located in Sanquhar, Scotland. It has been continuously operating since 1712—over 310 years of delivering mail!
Install Sanquhar and start sending beautiful emails with Razor templates.
@model WelcomeModel
<!DOCTYPE html>
<html>
<body>
<h1>Welcome, @Model.Name!</h1>
<p>
Thank you for joining on
@Model.Date.ToString("D").
</p>
</body>
</html>
Choose the provider that fits your needs. Switch anytime with minimal code changes.
Use any SMTP server including Gmail, Outlook, or your own mail server. Built on the reliable MailKit library.
Gmail, Outlook, Office 365, custom servers
Secure connections with full SSL/TLS support
Built on the industry-standard MailKit library
// appsettings.json
{
"Sanquhar": {
"TemplatePath": "EmailTemplates",
"Smtp": {
"Host": "smtp.gmail.com",
"Port": 587,
"Username": "your-email@gmail.com",
"Password": "your-app-password",
"EnableSsl": true
},
"Mail": {
"DefaultFrom": "noreply@yourdomain.com"
}
}
}
// Program.cs
using Noundry.Sanquhar.Extensions;
builder.Services.AddSanquhar(builder.Configuration);
Use SendGrid's powerful email API with built-in tracking, analytics, and deliverability features.
Track email opens and link clicks automatically
Test without sending real emails
High deliverability and scalability
// appsettings.json
{
"Sanquhar": {
"SendGrid": {
"ApiKey": "your-sendgrid-api-key",
"EnableClickTracking": true,
"EnableOpenTracking": true,
"SandboxMode": false
}
}
}
// Program.cs
using Noundry.Sanquhar.Extensions;
using Noundry.Sanquhar.SendGrid.Extensions;
builder.Services.AddSanquhar(
builder.Configuration,
options => options.UseSendGrid(builder.Configuration)
);
Powerful email API with excellent deliverability and developer-friendly features. No RestSharp dependency - uses native HttpClient!
Built with modern HttpClient and IHttpClientFactory
Track opens, clicks, and delivery status
Great API documentation and debugging tools
// appsettings.json
{
"Sanquhar": {
"Mailgun": {
"ApiKey": "your-mailgun-api-key",
"Domain": "your-domain.mailgun.org",
"ApiBaseUrl": "https://api.mailgun.net/v3",
"EnableTracking": true,
"EnableClickTracking": true
}
}
}
// Program.cs
using Noundry.Sanquhar.Extensions;
using Noundry.Sanquhar.Mailgun.Extensions;
builder.Services.AddSanquhar(
builder.Configuration,
options => options.UseMailgun(builder.Configuration)
);
See how easy it is to send emails with Sanquhar.
public class EmailService
{
private readonly IMailService _mailService;
public EmailService(IMailService mailService)
{
_mailService = mailService;
}
public async Task SendWelcome(
string email,
string name)
{
var model = new WelcomeModel
{
Name = name,
Date = DateTime.Now
};
await _mailService.SendFromTemplateAsync(
"Welcome", model, email);
}
}
var message = await _mailService
.CreateFromTemplateAsync(
"Invoice", model);
message.To.Add(customer.Email);
message.Cc.Add("manager@company.com");
// Add attachment
message.Attachments.Add(new MailAttachment
{
FileName = "invoice.pdf",
Content = pdfBytes,
ContentType = "application/pdf"
});
// Set priority
message.Priority = MailPriority.High;
await _mailService.SendAsync(message);
Built with the latest C# 13 and .NET 9 features for maximum performance and developer experience.
Modern C# 13 syntax with []
Proper HTTP client management
Compile-time regex generation