Getting Started with MailSlurp API
Getting Started with MailSlurp: Learn how to set up the SDK, obtain an API Key, and create email addresses in code or tests with ease.
MailSlurp is an email API that lets you create email addresses on demand in applications and tests using REST or SDK libraries. You can also send and receive emails directly in code or have them forwarded to an application endpoint.
Install an SDK
MailSlurp is available in many languages. You can see a list of all SDK libraries in the documentation section. The recommended client is written in Javascript and will be used in the examples.
npm install --save mailslurp-client
Obtain your API Key
All MailSlurp usage requires an API Key. Get your API Key free by signing up and logging into the MailSlurp dashboard.
Your API Key is shown on the Install
and Settings
page.
Configure your client
Next configure a MailSlurp instance with your API Key.
const { MailSlurp } = require("mailslurp-client");
const mailslurp = new MailSlurp({ apiKey: "your-api-key" });
Create an email address in code or tests
You can now easily create email addresses.
// create a randomly assigned email address
const inbox = await mailslurp.createInbox();
You can also send emails.
mailslurp.sendEmail(inbox.id, { to: ["test@example.org"] });
And fetch emails sent to an inbox.
const email = await mailslurp.waitForLatestEmail(inbox.id);
Next steps
See the documentation and examples for more information on getting started or see the GraphQL API endpoints if you prefer.