.NET / C#
Send transactional email from .NET apps using the official MailSetu .NET SDK.
Installation
bash
dotnet add package MailSetuSetup
csharp
using MailSetu;
var client = new MailSetuClient(
Environment.GetEnvironmentVariable("MAILSETU_API_KEY")!
);Send an email
csharp
var result = await client.Emails.SendAsync(new Dictionary<string, object?>
{
["from"] = "noreply@yourdomain.com",
["to"] = new[] { "user@example.com" },
["subject"] = "Welcome!",
["html"] = "<h1>Welcome!</h1><p>Thanks for signing up.</p>",
});
Console.WriteLine(result.GetProperty("id").GetString());Dependency injection (ASP.NET Core)
csharp
// Program.cs
builder.Services.AddSingleton<MailSetuClient>(sp =>
new MailSetuClient(builder.Configuration["MailSetu:ApiKey"]!));
// appsettings.json
{
"MailSetu": {
"ApiKey": "ms_live_your_key_here"
}
}