Email attachment size limit

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 specication 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();

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();

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.