MailSlurp API entities and how to use them

MailSlurp API entities and how to use them

MailSlurp is an abstraction layer over regular SMTP mail servers. It has unique data structures to represent email address and messages. Here is a quick overview of the models before we see how to use them.

Looking for help with the visual dashboard? See the dashboard guide.

Inbox

An inbox represents an email address. Each inbox has an id and an emailAddress associated with it.

interface Inbox {
  id: string;
  emailAddress: string;
}

Email

An email represents the contents and metadata of an email received by MailSlurp.

interface Email {
  id: string;
  to: Array<string>;
  subject?: string;
  body?: string;
  // ...other fields hidden
}

Attachment

MailSlurp extracts email attachments and stores them securely on disk. You can read meta data about attachment files

interface AttachmentMetaData {
  contentLength: number;
  contentType: string;
  name: string;
  // ...download contents with downloadAttachment() methods
}

Domain

MailSlurp lets you use custom domains to send and receive email. You can only use custom domains if you registered and verified the domain.

interface Domain {
  id: string;
  userId: string;
  domain: string;
  verificationToken: string;
  // ...other fields hidden
}

WebHook

WebHooks can be attached to inboxes you have created. WebHooks have a URL that should point to a backend service that you have access to. When emails are received by an inbox with a WebHook MailSlurp will post the ID of the email to your URL so that you can receive the emails asynchronously and at scale.

Collections

Many MailSlurp methods return collections of entities in a minimal form. For instance the getEmails() method returns a List<EmailPreview> that takes the following shape:

[
  {
    "id": "123"
  },
  {
    "id": "456"
  }
]

You are expected to use collection methods to find the entities you are looking for and then call the entity methods individually for each full entity you wish to consume. In this case you would call getEmail for each email you want to fetch fully.

Next steps

Now that we understand the key structures of MailSlurp let's create an inbox.

Related content

Email APIs for Developers & QA

Build powerful applications and test suites using real email addresses in code. Create inboxes on demand then send and r...

Official MailSlurp documentation

Developer documentation and guides for MailSlurp's email APIs. REST, SDKS, Graphql, SMTP and more. MailSlurp is an email...

Ruby Mailer SDK - send and receive emails in Rails, Rspec an...

Receive email and attachments with Rails, Rspec, and Ruby without SMTP using MailSlurp Ruby Gem.

Temporary email api

Temporary email API for disposable email accounts. Free for personal use with REST API and clients in NodeJS, CSharp and...

Mailinator alternative

Alternatives to Mailinator for test email accounts. Create real email addresses using MailSlurp

Generate API clients using Swagger

How to create SDK libraries a language of your choice

Ready to dive in?Start building email applications today.