A mail.tm / mail.gw API wrapper for .NET. These services have identical api at the moment, but this might change in future.
Available as a NuGet.
PM> Install-Package SmorcIRL.TempMail
mail.tm
is a great temporary/disposable mail service, and also recently was launched a new 10 minute mail service called mail.gw
. As I said, these two services have identical api, so all told about mail.tm
will be true for mail.gw
as well. Basically API calls require authorization, but some are not (getting domains info, for example). Having an authorized MailClient
instance, you can get its authorization token via BearerToken
property, that may be helpfull for manual debbuging using Swagger.
Interaction with account API is performed through a MailClient
instance. You can simply register like this
MailClient client = new MailClient();
await client.Register("[email protected]", "*password*");
You can also specify the base api url. The default refer to mail.tm, but if you want to use mail.gw, create a client like that
MailClient client = new MailClient(new Uri("https://api.mail.gw/"));
Make sure you specify the domain correctly - domains list is limited by the service. You can get an actual list using
DomainInfo[] domains = await client.GetAvailableDomains();
If you only need to get any valid domain name for you account
string domain = await client.GetFirstAvailableDomainName();
Now you can register using an overload that takes email and domain separately
string domain = await client.GetFirstAvailableDomainName();
await client.Register("pepethefrog", domain, "*password*");
If you already have an account, you can log in using your creds
await client.Login("[email protected]", "*password*");
If you need to get info about the account you are using, like creation date or message quota, call
AccountInfo info = await client.GetAccountInfo();
After your work with the account is done, you can delete it
await client.DeleteAccount();
After that you can reuse the client with new authorization via Login()
/Register()
if needed.
- Get info about all messages
MessageInfo[] messages = await client.GetAllMessages();
- Get info about all messages from the page
MessageInfo[] messages = await client.GetMessages(*page*);
- Get message info by id
MessageInfo message = await client.GetMessage("*id*");
- Get message source
MessageSource source = await client.GetMessageSource("*id*");
string rawMessage = source.Data;
- Mark as seen
await client.MarkMessageAsSeen("*id*", true);
- Delete
await client.DeleteMessage("*id*");