Videos
Check out our tutorial video series.
Manage your email attachments programmatically with MailSlurp's attachment endpoints. Upload, send, receive, and download files with ease.
MailSlurp offers an email attachment API so you can send and receive attachments in code or tests without a mailserver. Most actions use the endpoints. See the AttachmentController for method documentation.
The SMTP specification for email messaging lays out many official headers and properties of an email. It is however not very specific about attachments. Using the MIME spec, an email and its attachments are transfered using a string multipart messagethat is base64 encoded as 7-bit ASCII text. MailSlurp makes attachment encoding easy.
Attachments can be sent and received in tests and code or using the MailSlurp dashboard. Create a free account to get started.
Before you send an attachment first upload it in the dashboard. This will take care of the MIME encoding etc.
You can do the same in code using the AttachmentController endpoint. Take a file convert it into a Base64 encoded string. POST it to the endpoint and it will return an array whose first element is the ID of the uploaded attachment.
Here is an example of uploading an attachment in PHP:
The same methods apply for other languages. Here is the same example of base64 encoding a file in Javascript:
The MIME email standard does not specify a limit to attachments. See the email attachment size limits guide for more information.
Attachments that are sent to MailSlurp mailboxes are stored and are available by ID. They can be viewed in the dashboard or using the API.
You can wait for an expected emails using the . Retrieve an email to view the attachment IDS.
Call the to download an attachment as a base 64 encoded string. This makes consuming binary content easier for some clients. Base64 decode the content string to a byte array to access the file. This example uses the NodeJS library.
You can also call the method and MailSlurp returns an
of bytes in response. These can be streamed to disk or a buffer and read later.
Check out our tutorial video series.
Email and SMS guides for automation and testing.
View github project code for multiple languages.
Latest posts from the MailSlurp team.
Test, build, and automate messaging with a free MailSlurp account.