Email read (opened seen settings)
How to control the seen or read settings for an email using MailSlurp.
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.
Related content
Javascript email libraries for MailSlurp
Nodemailer alternatives to send and receieve email in code and tests
Fastest way to start a typescript project
Modern typescript tooling has come a long way. See how to setup a new project with TS-Node, TSC, and typeconfig.json.
Fetch error message javascript
Handle response exceptions with Fetch in Javascript
GraphQL API disposable email accounts
How to create real email addresses using GraphQL to send and receive emails in tests and frontend applications.
GraphQL Email API Tutorial
Did you know you can send and receive emails using GraphQL?
Hugo responsive image srcsets
Serve responsive picture tags with custom render-image layout partial in Hugo static site generator.
NodeMailer NPM Tutorial
Send and receive email using NodeMailer in Node JS.
Create custom print classes with Tailwind
Configure tailwind.config.js to create prefixed classes with a custom media query.
Send and receive email in Cypress JS tests with MailSlurp
Test email sign-up. password verification and more with Cypress JS and MailSlurp.
Cypress Email Plugin - Test email accounts in Javascript (an...
Use real email accounts in CypressJS to test user sign-up, email verification, and more.
Test email accounts with Jest and Puppeteer
Test email accounts in React with Jest and Puppeteer. Send and receive emails in Javascript.
Test user sign-up with NodeJS and WebDriver
Test email related processes like sign-up and verification using WDIO WebDriver and MailSlurp.
TestCafe end-to-end MFA testing for user sign-up and email v...
End-to-end testing with MailSlurp, NodeJS, and TestCafe.
Base64 file uploads
How to encode files as Base 64 encoded strings in several languages
Deno Email Apis
Send and receive emails in Deno JS. Use APIs in Deno with MailSlurp.
Email read (opened seen settings)
How to control the seen or read settings for an email using MailSlurp.
GraphQL Email API
Fetch and read emails with GraphQL inboxes using MailSlurp email API.
Testing OTP password link username and password for 2 factor...
Testing OTP password link username and password for 2 factor authentication (2FA)
MailSlurp NodeMailer SMTP Usage
Use SMTP nodemailer with MailSlurp disposable email addresses
Testing email with Cypress test email accounts
Test email accounts for CypressJS. End-to-end testing with real email addresses using MailSlurp Cypress plugin.
Send emails in NodeJS using SMTP
How to use Javascript SMTP client (or Nodemailer) to send email with MailSlurp mail server
Testing Email with Cypress JS and MailSlurp
Email testing with Cypress JS