MailSlurp NodeMailer SMTP Usage

Use SMTP nodemailer with MailSlurp disposable email addresses

You can use MailSlurp's unlimited throw away email accounts to send and receive email in NodeJS using Nodemailer. Here is an example using both clients:

const nodemailer = require("nodemailer")
const {MailSlurp} = require('mailslurp-client');

describe('node mailer smtp usage', () => {
    let config;

    beforeAll(() => {
        // provide a mailslurp API KEY
        const apiKey = process.env.API_KEY;
        // create config for clients and main class
        config = {apiKey};

    it('can create smtp inbox then send email to it with nodemailer', async () => {
        const mailslurp = new MailSlurp(config);
        const inbox = await mailslurp.createInbox();

        const transport = nodemailer.createTransport({
            host: "",
            port: 2525,
            secure: false

        const sent = await transport.sendMail({
            from: '"Fred Foo 👻" <>',
            to: inbox.emailAddress,
            subject: "Hello ✔",
            text: "Hello world?",
            html: "<b>Hello world?</b>",

        const email = await mailslurp.waitForLatestEmail(, 30000, true)

Ready to dive in?Start building email applications today.