MailSlurp logo

blog

Email attachment size limits: what actually sets the maximum?

Understand how MIME encoding affects email attachment size, why providers set practical limits, and how to upload and send attachments with MailSlurp.

Email attachment size limits: what actually sets the maximum? article preview

There is no single attachment limit that applies to every email. The practical maximum is set by the systems on both sides of a message: the sending API or server, any gateway in between, and the recipient's mailbox provider. If an attachment matters to a signup, invoice, or support workflow, test the delivered message instead of assuming the sender's accepted response proves the file arrived.

What sets the maximum attachment size?

Email standards describe how a file is represented inside a message, but providers and APIs still enforce their own message size limits. The smallest limit along the delivery path wins. A message can therefore be accepted by one server and rejected later by another.

What defines an attachment?

An attachment is one part of a MIME message. Binary files are commonly Base64 encoded for transport, which increases their size by roughly one third before headers and MIME boundaries are added. That means a 20 MB file can produce a message of about 27 MB even before the rest of the email is counted.

What does this mean in practice?

Check the full message size rather than the original file size, leave room for encoding overhead, and test against the same providers your customers use. For larger files, a secure download link is often more reliable than pushing every byte through the email delivery path.

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 returned attachment ID to send it with an email. Here is another example in Java:

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 programming languages.

Use email attachments now

To start sending and receiving attachments in code, create a free MailSlurp account and review the email size limits guide.