A C# SDK for interacting with the TempMail.so API to create and manage temporary email addresses.
- Create temporary email inboxes
- List available domains
- Manage inboxes and emails
- Retrieve email contents
- Full async/await support
- Strong typed models
- Simple and intuitive API
- Copy
TempMailSo.csto your project - Add the following NuGet packages:
- System.Text.Json
- System.Net.Http
To use this SDK, you'll need:
- A RapidAPI key from TempMail.so RapidAPI page
- An auth token from TempMail.so
- .NET Core 3.1 or later
// Initialize the client
var client = new TempMailSoClient("YOUR_RAPIDAPI_KEY", "YOUR_AUTH_TOKEN");
// Create a new inbox
var inbox = await client.CreateInboxAsync();
Console.WriteLine($"New email address: {inbox.Email}");
// Get available domains
var domains = await client.GetDomainsAsync();
foreach (var domain in domains)
{
Console.WriteLine($"Available domain: {domain}");
}
// Get messages from inbox
var messages = await client.GetMessagesAsync(inbox.Email);
foreach (var message in messages)
{
Console.WriteLine($"Subject: {message.Subject}");
// Get message details
var messageDetails = await client.GetMessageAsync(message.Id);
Console.WriteLine($"Message content: {messageDetails.TextBody}");
}The main class for interacting with the TempMail.so API.
public TempMailSoClient(string rapidApiKey, string authToken)CreateInboxAsync(): Creates a new temporary email inboxGetDomainsAsync(): Retrieves list of available domainsGetMessagesAsync(string email): Gets all messages for a specific email addressGetMessageAsync(string messageId): Gets detailed information about a specific messageDeleteMessageAsync(string messageId): Deletes a specific messageDeleteInboxAsync(string email): Deletes an inbox and all its messages
Email: The full email addressCreatedAt: Timestamp of inbox creation
Id: Unique message identifierFrom: Sender's email addressSubject: Message subjectPreview: Short preview of message contentHasAttachments: Boolean indicating if message has attachmentsCreatedAt: Timestamp of message receipt
Id: Unique message identifierFrom: Sender's email addressSubject: Message subjectTextBody: Plain text contentHtmlBody: HTML contentAttachments: List of attachmentsHeaders: Email headersCreatedAt: Timestamp of message receipt
The SDK throws TempMailSoException when API requests fail. Always wrap API calls in try-catch blocks:
try
{
var inbox = await client.CreateInboxAsync();
}
catch (TempMailSoException ex)
{
Console.WriteLine($"API Error: {ex.Message}");
}
catch (Exception ex)
{
Console.WriteLine($"General Error: {ex.Message}");
}The API has rate limits based on your RapidAPI subscription plan. The SDK will throw a TempMailSoException with appropriate error message when rate limits are exceeded.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
For API-related issues, please contact TempMail.so support through their RapidAPI page. For SDK-specific issues, please open an issue in this repository.