Send and receive email attachments. How to attach files to SMTP emails.

smtp attachments Attachments are a way to send and receive files with in emails.

Sending attachments

Send attachments using the compose page in the dashboard or by using the sendEmail methods with a list of attachment IDs. Attachment IDs can be created by uploading files before sending (see next section). Here is an example using the NodeJS client:

await mailslurp.sendEmail(!, {
  to: [inbox.emailAddress!],
  subject: 'attachment test',
  attachments: [attachmentId.toString()],

Uploading attachments

To upload attachments use the upload attachment method and pass a base64 encoded string for the file content. An array containing an attachment ID will be returned. Use the attachment ID to send the attachment or download it.

// notice that an array with one attachment id is returned
const [attachmentId] = await mailslurp.uploadAttachment({
  base64Contents: Buffer.from('hello').toString('base64'),
  contentType: 'text/plain',
  filename: 'test.txt',

Downloading attachments

Here is how to download files found on an email object.

const attachment =
  await mailslurp.attachmentController.downloadAttachmentAsBase64Encoded({
    attachmentId: email.attachments?.[0]!,
const content = new Buffer(