I know the maximum email size is 20 MB, so why am I getting an error when my attachment is well under that limit?

Emails follow the MIME standard. This means that all content in an email — plain text, HTML, and attachments — is encoded to be MIME-compliant. MIME encoding can make content larger than the original files.

This means an email whose total content is well under 20 MB can result in a MIME-encoded email that exceeds 20 MB, which triggers the error. Please read more about the maximum email size for further context.

You can try compressing attachments before adding them to the email. Keep in mind that this may not reduce the size enough if the attachment already contains compressed content — this is common with PDF files, for example.