MailSlurp has an official Go library hosted on GitHub. You can use this library to call the MailSlurp API in Go!

Let's use MailSlurp to test email related processes using the popular library for assertions.


First add MailSlurp:

We will also add test libraries and context:

Import and configure

Now create a test file called . Import and configure MailSlurp in your test like so:

We can now create MailSlurp API clients using

Create inboxes

MailSlurp inboxes can be created on demand and have an ID and an email address.

Let's see how you create one:

Send emails

You can send emails in Go tests by first creating an inbox and then using the method:

Receive emails (and extract content)

MailSlurp is unique in allowing you to receive emails in Go. No MailServer is required. First create an inbox then use the methods to wait for unread emails to arrive.

You can receive emails using the :

Next steps

See the source code for full method documentation.