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;
}
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
Send email with Axios JS (and receive email too!)
Send email in Javascript with MailSlurp email API
Email attachments API to send and download attachments in co...
Use MailSlurp's attachment endpoints to upload, send, receive, and download attachments.
Using custom domains with MailSlurp
Email custom domains with API access
Create email inboxes using MailSlurp's API
Create email inboxes using MailSlurp's API
MailSlurp API entities and how to use them
MailSlurp API entities and how to use them
Get emails from code (how to receive emails programmatically...
How to receive emails directly in code, applications, and tests. Use MailSlurp to send and receive SMTP emails.
Sending email in Javascript and NodeJS (Typescript examples)
Sending email in Javascript and NodeJS (Typescript examples)