Introduction
Most email providers impose a maximum message size limit, typically 25MB for consumer services. When an email with attachments exceeds this limit -- after Base64 encoding increases the attachment size by approximately 33% -- the sending or receiving server rejects the message. This is a common issue when sending large documents, images, or datasets via email.
Symptoms
- Email bounces with
Message size exceeds fixed limitor552 Message too large - Sending client shows
Attachment too largeerror - Email appears to send successfully but bounces from the receiving server
- Multiple recipients experience the same rejection
- Error message:
552 5.3.4 Message size exceeds fixed limit of 26214400 bytes
Common Causes
- Attachment file size close to or exceeding 25MB before encoding
- Multiple attachments whose combined size exceeds the limit
- Base64 encoding increasing the attachment size by ~33%
- Email body content (HTML, embedded images) adding to total message size
- Receiving server has a lower size limit than the sending server
Step-by-Step Fix
- 1.Check the actual message size including encoding overhead: Calculate the true size.
- 2.```bash
- 3.# Check file size before encoding
- 4.ls -lh document.pdf
- 5.# Estimate encoded size (multiply by 1.37 for Base64)
- 6.# A 20MB file becomes approximately 27.4MB after encoding
- 7.
` - 8.Compress the attachment to reduce size: Use efficient compression.
- 9.```bash
- 10.# Compress with zip
- 11.zip -9 document.zip document.pdf
- 12.# Or split into smaller parts
- 13.split -b 10m document.pdf document_part_
- 14.# Send parts in separate emails
- 15.
` - 16.Use cloud storage links instead of attachments: Bypass size limits entirely.
- 17.
` - 18.# Upload the file to:
- 19.# - Google Drive, Dropbox, OneDrive
- 20.# - Company file sharing service
- 21.# - WeTransfer or similar temporary file service
- 22.# Include the download link in the email body
- 23.
` - 24.Configure the mail server size limit if self-hosted: Adjust server settings.
- 25.```bash
- 26.# For Postfix, increase the message size limit
- 27.postconf -e "message_size_limit = 52428800" # 50MB
- 28.systemctl restart postfix
- 29.# Note: receiving server limits still apply
- 30.
` - 31.Verify the email delivers successfully: Test with the reduced attachment.
- 32.```bash
- 33.# Send a test email
- 34.echo "Test with compressed attachment" | mail -s "Test" -A document.zip recipient@example.com
- 35.# Check delivery confirmation
- 36.
`
Prevention
- Set attachment size limits in email clients to warn before exceeding provider limits
- Use cloud storage links as the default method for files over 5MB
- Compress attachments before sending to minimize encoded size
- Document the email size limits for common providers (Gmail: 25MB, Outlook: 20MB)
- Implement server-side attachment size checks before accepting large messages
- Consider dedicated file transfer services for regular large file sharing needs