Determine actual message size limit when you only get “552 5.3.4 Message size exceeds fixed limit”
Posted by jpluimers on 2020/03/26
Often when you send large emails the only reply you get is a non-descriptive message like 552 5.3.4 Message size exceeds fixed limit from the SMTP server without an indication what the limit actually is.
Most SMTP servers however implement extensions in the EHLO greeting that returns a SIZE mail parameter. You can query it by hand using this:
telnet aspmx.l.google.com smtp Trying 108.177.119.27... Connected to aspmx.l.google.com. Escape character is '^]'. 220 mx.google.com ESMTP 32si3005669edb.510 - gsmtp EHLO example.org 250-mx.google.com at your service, [80.100.143.119] 250-SIZE 157286400 250-8BITMIME 250-STARTTLS 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-CHUNKING 250 SMTPUTF8 QUIT 221 2.0.0 closing connection 32si3005669edb.510 - gsmtp Connection closed by foreign host.
There you can see the maximum message size at the time of writing is 157286400 bytes which is about 150 megabytes.
There is a nice Python script showing how to obtain it at [WayBack] Getting Information from EHLO | Erle Robotics Python Networking Gitbook Free (note this one does send an email, so you might want to trim the example if you just want to see the size).
More background reading:
- [WayBack] RFC 2821 – Simple Mail Transfer Protocol: 4.1.1.1 Extended HELLO (EHLO) or HELLO (HELO)
- [WayBack] RFC 1870 – SMTP Service Extension for Message Size Declaration
- [WayBack] MAIL Parameters: SMTP Service Extensions
- Python
smtplib.SMTP.ehlo(also documentsesmtp_features)smtplib.SMTP.has_extn
- [WayBack] mail server – “Error: message file too big” Is the limit on outgoing or receiving end? – Stack Overflow
Trimming down the Python script so it queries message size for each mail server of a domain
This turns out to be a tad more complex, because DNS functionality isn’t part of core Python, and the rdata part of DNS records ends with a dot, which might not be usable with the SMTP library.
References for me when trimming down:
- [WayBack] Chapter 15 DNS Messages: RDATA
- [WayBack] python – Why do mxrecord should be change to string? – Stack Overflow
- [WayBack] Python Email Verification Script – Scott Brady
- [WayBack] python – How do we get TXT, CNAME and SOA records from dnspython? – Stack Overflow
- [WayBack] dnspython home page (install with
pip installorpip install --user
–jeroen






Leave a comment