Temp Mail API Tutorial

As the name implies, Temp Mail API allows you to create temporary email ids. These email ids are created on the fly and are disposable. Temporary email keeps your original email safe. You can use temporary emails for online subscriptions, email verification, and instant notifications. A temporary email id can be thrown away or discarded after use.

The Temp Mail API gives you the power to access your temporary email inbox. You can read the mails, extract the attachments, delete mails. You can do all this without signing up for an email id. If you are wondering how is it possible and how can temp emails help your business, you are soon going to learn everything about how to make the best use of temporary email services.

Begin by logging in to your Rakuten RapidAPI account and head over to the Temp Mail API Console.

In case you don’t have an account on Rakuten Rapid API, sign up now and get your universal API key to access the Temp Mail API and thousands of other APIs hosted on Rakuten RapidAPI.

The Novelty of Temporary Email IDs

The choice of email id is a personal preference. You may have spent some time choosing an email id that best suits your name or persona. However, there are certain situations, as mentioned in the last section, when you would be better off using a separate email id which acts as a dump for all the spam and temporary notifications that you get.

For businesses, temporary email API service is a good choice under certain use cases

Business Process Automation via Disposable Email

Emails are an effective tool for business process automation tasks. For example, if you are planning to conduct a meetup and want people to RSVP via email, then you can use a temporary email. Meetups and corporate gatherings are ephemeral events and it is best to use a temporary disposable email id to manage them.

Anonymous Communication

The most significant security risk of any communication is the very act of communicating itself. When you send an SMS to a person, that person gets to know your mobile number. The same is the case with emails as well. There are certain business situations, where you might want to mask off your real email id. It also helps avoid spam if someone responds to those mailers.

This use case also applies to transactional emails. Your business deals with a lot of external vendors and partners with whom you have regular transactions. It is best to use temporary emails for notifying updates on such transactions to safeguard the privacy of actual user initiating the transaction.

Shared Email Notifications

Disposable emails are also suitable as a shared, receive only notifications.

Let’s assume that your business operations involve performing certain activities by a contract field team and they also need to be updated about specific events. Allocating email ids to every person of the contract team is an administrative overhead. It is more convenient to define a single temporary email id that acts as a shared notification channel for the entire team.

Managing Temporary Disposable Emails with Temp Mail API

The Temp Mail API offers the right mix of features to manage disposable emails. First of all, this temporary email API supports open email ids that do not require sign-ups. With Temp Mail API you can create an email id, except the domain name part which is pre-decided by the API, and then send an email to that id. The Temp Mail API fetches the mail contents for you and retains it for a period of time.

As a regular email user, this may sound pretty awkward to you. So let’s take the Temp Mail API for a quick test drive to understand what it means to deal with a disposable email id.

Before you try your hands on the Temp Mail API endpoints, take a look at the “Pricing” tab and subscribe to the BASIC plan. The basic plan gives you 100 free API calls per day.

Once subscribed, go back to the “Endpoints” tab and select the “GET Domains list” endpoint and trigger the API.

The API response (highlighted in blue) contains the available domains for the temporary email ids that this API supports. It means that you can create a random email user id and append any of these domains for a valid temporary email address.

Let’s see if this works.

Open your fav email client and send an email to temp001@s0nny.com. Here s0nny.com is one of the domain names listed in the API response, and temp001 is a random id.

Once you send the mail, come back to the API console and choose the “GET Get emails” endpoint.

Now then, hit the “Test Endpoint” button and see what you get as the response.

Voila! That’s the same email you sent just now. You now have a temporary email id, temp001@s0nny.com, and you can access its mailbox via the API.

MailBox Management with Temp Mail API

The Temp Mail API is not only about receiving emails. You can also perform some of the typical mailbox operations that you are used to doing manually with email clients. For instance, the API supports endpoints to access individual mail messages, attachments, and even deletion of mail message.

Working With Individual Messages

GET Get one message

The “GET Get one message” endpoint fetches an individual mail message from the mailbox. Every message received by the API has a unique id. If you look at the mail message that you received for temp001@s0nny.com, you can find it in the JSON response key “mail_id”.

You can call this endpoint using this id.

Subsequently, you get the same message in API response.

GET Delete message

The “GET Delete message” accepts the same “mail_id” to delete individual mail messages from the mailbox.

To confirm that the message was deleted from the mailbox, trigger the “GET Get emails” endpoint again. This time the API returns an error response indicating that there are no emails in the mailbox.

Working With Mail Attachments

The Temp Mail API also supports the listing and retrieval of attachments.

You can use the “GET Get message attachments” and “GET Get one attachment” endpoints to retrieve all attachments within a mail message or a single attachment.

As an example, if you send an email to temp001@s0nny.com with an image file as attachment, the API response is:

This response contains the metadata about the attachment. To retrieve the actual content of the attached file, you can invoke the “GET Get message attachments”. For this, you have to use the same “mail_id” key to uniquely identify the mail message and pass it to the ‘md5’ parameter of the endpoint.

The response contains the image content as a base64 string.

You can extract the entire content of the attached image from the “content” key of the JSON response. Note that in the above figure, the value of the “content” key is truncated as it is a very long string.

Winding Up

That’s a wrap on this API tutorial . You now have a fair idea of what is possible with temporary email ids. So, go ahead and build one of the business use cases that we described at the beginning of this tutorial.

You can also check our Top 10 Email APIs for more options on choosing an API for your project.