How to fetch email message and attachments in code
How to read emails and attachments in applications, tests, or the MailSlurp dashboard. Fetch SMTP messages body parts, headers, and files.
See the full email receive guide for more information.
You can use MailSlurp to capture real emails and attachments in applications, tests, or using the MailSlurp Dashboard.
In order to receive emails with MailSlurp you must first create an inbox. Each inbox has an
id and an
emailAddress. Any email sent to the inbox's email address will be captured by MailSlurp and stored in the inbox.
Note: emails can take up to a minute to arrive. This is due to the asynchronous nature of SMTP and email. If you developing with MailSlurp considering using Webhooks or waitFor methods.
Listing received emails
You can see a list of all the emails an inbox has received on the overview page for a given inbox. You can also use the
getEmails(inboxId) methods in the SDKs libraries.
Viewing email content
You can view the content of an email by clicking view in the inbox overview page or by using the
getEmail(emailId) methods in the API.
The Dashboard email overview page contains a number of sections. The first is an overview of the email including the
The body of an email is available in several formats: plain-text, HTML preview, and RAW.
MailSlurp renders a real HTML preview of your email. Note some email clients may render results differently. Images are available for paid plans.
Raw SMTP email content is available under the RAW tab in the content pane. This is useful for deep email analysis.
You can capture and download real attachments with MailSlurp in code, tests, or using the Dashboard.
If an email was received that contained attachments they will be listed in the attachments section. The can also be obtains via the
downloadAttachment(attachmentId) developer endpoints.
MailSlurp performs powerful SPAM analysis on every email. You can view the results in the email analysis section: