Skip to content

onmicroIT/mail.tm

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mail.tm

A mail.tm / mail.gw API wrapper for .NET. These services have identical api at the moment, but this might change in future.

Installation

Available as a NuGet.

PM> Install-Package SmorcIRL.TempMail

Getting started

Introduction

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.

Register

Interaction with account API is performed through a MailClient instance. You can simply register like this

MailClient client = new MailClient();
await client.Register("pepethefrog@sad.me", "*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*");

Log in

If you already have an account, you can log in using your creds

await client.Login("pepethefrog@sad.me", "*password*");

Get account info

If you need to get info about the account you are using, like creation date or message quota, call

AccountInfo info = await client.GetAccountInfo();

Delete account

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.

Working with messages

  • 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*");

About

A mail.tm API wrapper for .NET

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • C# 100.0%