Did you know you can use GraphQL to send and receive emails? That's right - there is a free API at graphql.mailslurp.com you can use to create disposable email accounts for testing and application development.

Create a test project

Use NPM to initialize a new node project and add the AVA test library (you can use any test library you wish).

Then add the library so we can call the GraphQL endpoints.

Our package json now looks something like this:

To use ESM style imports add the flag to your package.

Configure a graphql client for email accounts

Create an file and add the code below:

Testing disposable email accounts with AVA

Now we have a client let us write some tests to demonstrate usage of email accounts. Create a file and add a test.

If we run we will see passing tests in your console output.

Given that the dummy tests are passing we can add queries to our test to create a disposable email account, send and email to it and receive said email.

Create an email address with GraphQL

Create a new disposable email account using MailSlurp's mutation. Use a custom domain for permanent inboxes.

Send emails

Receive and read emails in GraphQL