Email attachment size limit

Email MIME type message attachment file size limits and conventions

Email API services like MailSlurp let you send and receive email attachments in code and tests.

What is the maximum size of an attachment

Is there an email attachment size limit? NO. Not officially. The MIME email specification makes no mention of a file size limit - it isn't very clear about attachments in generally though.

What defines an attachment?

Attachments are just another part of an email message body. By convention email attachments are converted to 7bit ascii strings via base 64 encoding. These large strings represent a files bytes as a string of characters. The characters plus meta data like name and content type are included in the email message as parts of a multi-part encoded string.

What does this all mean?

It means that the email can be of any length and therefore so can the attachments. In reality email providers may provide limits that they consider reasonable such as 50mb in some Gmail accounts for instance.

How to send attachments

Use MailSlurp's online dashboard or the email API to upload and send attachments. Here is an example in Java:

Upload attachments in code

AttachmentControllerApi attachmentControllerApi = new AttachmentControllerApi();

byte[] bytes = {0}; // test file, in reality read a file or input stream as bytes;
UploadAttachmentOptions uploadAttachmentOptions = new UploadAttachmentOptions();
uploadAttachmentOptions.setFilename("test.txt");
uploadAttachmentOptions.contentType("text/plain");
uploadAttachmentOptions.base64Contents(Base64.getEncoder().encodeToString(bytes));

List<String> attachmentIds = attachmentControllerApi.uploadAttachment(uploadAttachmentOptions);

Send attachment in code

After uploading an attachment use the reutrn attachment ID to send it with an email. Here is another example in Java again:

SendEmailOptions sendEmailOptions = new SendEmailOptions();
sendEmailOptions.setAttachments(attachmentIds);
sendEmailOptions.setTo(Collections.singletonList(inbox2.getEmailAddress()));

inboxControllerApi.sendEmail(inbox1.getId(), sendEmailOptions);

MailSlurp has a REST API and sdk libraries available in many other programming langauges.

Use email attachments now

To get started using email attachment and without any email attachment size limit create a free MailSlurp account today.

Related content

Send attachments with an Email API

How to send email attachments using MailSlurp API.

Email attachment size limit

Email MIME type message attachment file size limits and conventions

and space in HTML tips and techniques

Non breaking spaces in HTML and email content. How to handle HTML entities in code and tests.

Base64 file uploads

How to encode files as Base 64 encoded strings in several languages

Email attachments API to send and download attachments in co...

Use MailSlurp's attachment endpoints to upload, send, receive, and download attachments.

Ready to dive in?Start building email applications today.