Docs .NET verification email
.NET verification email
Send a verification or transactional email from .NET with HttpClient and X-API-Key.
There is no official .NET package yet. Use HttpClient against https://api.resendermail.com with the X-API-Key header.
Prerequisites
- Verified sending domain and sender identity (Get started)
- API key in configuration or environment as
RESENDERMAIL_API_KEY(never in a public client)
Send a verification email
using System.Net.Http.Headers;
using System.Net.Http.Json;
using System.Text.Json.Serialization;
public sealed record SendEmailRequest(
string From,
string[] To,
string Subject,
string? Html = null,
string? Text = null,
string? ReplyTo = null
);
public sealed record SendEmailResponse(
[property: JsonPropertyName("id")] string Id,
[property: JsonPropertyName("status")] string Status
);
public sealed class ResenderMailClient(HttpClient http, string apiKey)
{
public async Task<SendEmailResponse> SendAsync(
SendEmailRequest body,
CancellationToken cancellationToken = default)
{
using var request = new HttpRequestMessage(
HttpMethod.Post,
"https://api.resendermail.com/api/v1/emails");
request.Headers.TryAddWithoutValidation("X-API-Key", apiKey);
request.Content = JsonContent.Create(body);
using var response = await http.SendAsync(request, cancellationToken);
response.EnsureSuccessStatusCode();
return (await response.Content.ReadFromJsonAsync<SendEmailResponse>(
cancellationToken: cancellationToken))!;
}
}
// Example: after you create a verification token in your app
var client = new ResenderMailClient(new HttpClient(), Environment.GetEnvironmentVariable("RESENDERMAIL_API_KEY")!);
var verifyUrl = $"https://yourapp.com/verify?token={token}";
var result = await client.SendAsync(new SendEmailRequest(
From: "Your App <noreply@yourdomain.com>",
To: [userEmail],
Subject: "Verify your email",
Html: $"<p><a href=\"{verifyUrl}\">Verify email</a></p>",
Text: $"Verify your email: {verifyUrl}"
));
// result.Status is typically "Queued"; delivery is asynchronous.
JSON property names for the request body are camelCase (from, to, subject, html, text, replyTo) to match the API. If your serializer emits PascalCase by default, configure camelCase for this client.
Look up status
using var request = new HttpRequestMessage(
HttpMethod.Get,
$"https://api.resendermail.com/api/v1/emails/{id}");
request.Headers.TryAddWithoutValidation("X-API-Key", apiKey);
using var response = await http.SendAsync(request);
response.EnsureSuccessStatusCode();
See Send email for status values and error codes.