Email read (opened seen settings)

With MailSlurp received emails are marked as unread when they are processed. Unread emails are bold in the user interface and can be fetched with the unreadOnly flag with many wait for methods. Sometimes you may want to control the read behavior manually - for this you can use the email controller markAsRead method and pass a boolean:

Javascript example

You can use the markAsRead API method with any framework. Here is an example using the Javascript client.

import { MailSlurp } from 'mailslurp-client';

const timeout = 120001;
const mailslurp = new MailSlurp({ apiKey: process.env.apiKey });
jest.setTimeout(timeout);

describe("email read", () => {
test("can receive unread emails and set the read status", async () => {
const inbox = await mailslurp.createInbox()
await mailslurp.sendEmail(inbox.id!,{ to: [inbox.emailAddress!], subject: 'hello'})
// can get an unread email
const emails = await mailslurp.waitForEmailCount(2, inbox.id, timeout, true)
expect(emails.length).toEqual(2)
expect(emails[1].read).toEqual(false)

        // fetching email directly marks as read
        const email = await mailslurp.getEmail(emails[1].id!)
        expect(email.read).toEqual(true)

        // can set read value to true or false
        const emailPreview = await mailslurp.emailController.markAsRead(email.id!, false)
        expect(emailPreview.read).toEqual(false)
    })
})

Dashboard control

You can also set email seen settings on the email page using the settings dropdown.