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 limit or 552 Message too large
  • Sending client shows Attachment too large error
  • 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. 1.Check the actual message size including encoding overhead: Calculate the true size.
  2. 2.```bash
  3. 3.# Check file size before encoding
  4. 4.ls -lh document.pdf
  5. 5.# Estimate encoded size (multiply by 1.37 for Base64)
  6. 6.# A 20MB file becomes approximately 27.4MB after encoding
  7. 7.`
  8. 8.Compress the attachment to reduce size: Use efficient compression.
  9. 9.```bash
  10. 10.# Compress with zip
  11. 11.zip -9 document.zip document.pdf
  12. 12.# Or split into smaller parts
  13. 13.split -b 10m document.pdf document_part_
  14. 14.# Send parts in separate emails
  15. 15.`
  16. 16.Use cloud storage links instead of attachments: Bypass size limits entirely.
  17. 17.`
  18. 18.# Upload the file to:
  19. 19.# - Google Drive, Dropbox, OneDrive
  20. 20.# - Company file sharing service
  21. 21.# - WeTransfer or similar temporary file service
  22. 22.# Include the download link in the email body
  23. 23.`
  24. 24.Configure the mail server size limit if self-hosted: Adjust server settings.
  25. 25.```bash
  26. 26.# For Postfix, increase the message size limit
  27. 27.postconf -e "message_size_limit = 52428800" # 50MB
  28. 28.systemctl restart postfix
  29. 29.# Note: receiving server limits still apply
  30. 30.`
  31. 31.Verify the email delivers successfully: Test with the reduced attachment.
  32. 32.```bash
  33. 33.# Send a test email
  34. 34.echo "Test with compressed attachment" | mail -s "Test" -A document.zip recipient@example.com
  35. 35.# Check delivery confirmation
  36. 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