MailAPIFreetools 1.0.0
See the version list below for details.
dotnet add package MailAPIFreetools --version 1.0.0
NuGet\Install-Package MailAPIFreetools -Version 1.0.0
<PackageReference Include="MailAPIFreetools" Version="1.0.0" />
<PackageVersion Include="MailAPIFreetools" Version="1.0.0" />
<PackageReference Include="MailAPIFreetools" />
paket add MailAPIFreetools --version 1.0.0
#r "nuget: MailAPIFreetools, 1.0.0"
#:package MailAPIFreetools@1.0.0
#addin nuget:?package=MailAPIFreetools&version=1.0.0
#tool nuget:?package=MailAPIFreetools&version=1.0.0
MailAPI Freetools - .NET Client
A .NET 8 client library for the MailAPI Freetools temporary email service. Generate temporary email addresses and read emails programmatically.
Features
- ✅ Generate temporary email addresses
- ✅ Fetch emails from temporary addresses
- ✅ Health check endpoint
- ✅ Fully async/await support
- ✅ Comprehensive XML documentation
- ✅ Built-in error handling
- ✅ Supports dependency injection
Installation
Install the package via NuGet Package Manager:
Install-Package MailAPIFreetools
Or via .NET CLI:
dotnet add package MailAPIFreetools
Usage
Basic Usage
using MailAPIFreetools;
// Initialize the client with your API key
var client = new TempMailClient("your-api-key-here");
// Generate a temporary email address
var emailResponse = await client.GenerateEmailAsync();
Console.WriteLine($"Generated email: {emailResponse.GenerateEmail}");
// Fetch emails for the generated address
var emailsResponse = await client.GetEmailsAsync(emailResponse.GenerateEmail);
Console.WriteLine($"Received {emailsResponse.Messages.Count} emails");
// Display emails
foreach (var message in emailsResponse.Messages)
{
Console.WriteLine($"From: {message.SenderEmail}");
Console.WriteLine($"Subject: {message.Subject}");
Console.WriteLine($"Received: {message.ReceivedAt}");
Console.WriteLine($"Message: {message.Message}");
Console.WriteLine($"Links: {string.Join(", ", message.Links)}");
Console.WriteLine("---");
}
// Health check
var pingResponse = await client.PingAsync();
Console.WriteLine($"API Status: {pingResponse.Status}");
// Don't forget to dispose
client.Dispose();
Using with Dependency Injection
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using MailAPIFreetools;
var builder = Host.CreateApplicationBuilder(args);
// Register HttpClient and TempMailClient
builder.Services.AddHttpClient<TempMailClient>();
builder.Services.AddScoped<TempMailClient>(provider =>
{
var httpClient = provider.GetRequiredService<HttpClient>();
return new TempMailClient("your-api-key-here", httpClient);
});
var app = builder.Build();
// Use the client
using var scope = app.Services.CreateScope();
var client = scope.ServiceProvider.GetRequiredService<TempMailClient>();
var emailResponse = await client.GenerateEmailAsync();
Console.WriteLine($"Generated email: {emailResponse.GenerateEmail}");
Error Handling
The client throws the following exceptions:
ArgumentException
: When required parameters are null or emptyHttpRequestException
: When API requests failJsonException
: When response deserialization fails
try
{
var client = new TempMailClient("your-api-key-here");
var emailResponse = await client.GenerateEmailAsync();
// Use the response...
}
catch (HttpRequestException ex)
{
Console.WriteLine($"API request failed: {ex.Message}");
}
catch (JsonException ex)
{
Console.WriteLine($"Failed to parse response: {ex.Message}");
}
catch (ArgumentException ex)
{
Console.WriteLine($"Invalid parameter: {ex.Message}");
}
API Reference
TempMailClient
The main client class for interacting with the MailAPI Freetools service.
Constructor
TempMailClient(string apiKey, HttpClient? httpClient = null)
apiKey
: Your API key for the MailAPI Freetools servicehttpClient
: Optional HttpClient instance. If not provided, a new one will be created.
Methods
GenerateEmailAsync
Task<EmailGenerationResponse> GenerateEmailAsync(CancellationToken cancellationToken = default)
Generate a fresh temporary email address.
GetEmailsAsync
Task<EmailsResponse> GetEmailsAsync(string email, CancellationToken cancellationToken = default)
Fetch all emails received by the specified temporary email address.
PingAsync
Task<PingResponse> PingAsync(CancellationToken cancellationToken = default)
Perform a health check on the API service.
Models
EmailGenerationResponse
Response from the email generation endpoint.
Status
: Status of the requestGenerateEmail
: The generated temporary email addressMailsEndpoint
: Endpoint URL for fetching emailsUptime
: Email uptime in daysContact
: Contact information
EmailsResponse
Response from the emails endpoint.
Status
: Status of the requestEmail
: The queried email addressMessages
: List of received messages
EmailMessage
Individual email message.
SenderEmail
: Sender's email addressSubject
: Email subjectReceivedAt
: When the email was received (UTC)CreatedAt
: When the email was created (UTC)Message
: Email content/bodyLinks
: Links found in the email
PingResponse
Response from the ping endpoint.
Status
: API service status
Requirements
- .NET 8.0 or later
- Valid API key from MailAPI Freetools
License
MIT License
Support
For support, please contact the MailAPI Freetools team at their Telegram: @deleteduser864
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Microsoft.Extensions.Http (>= 8.0.1)
- System.Text.Json (>= 8.0.6)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.