Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check the email message size limit with Python

Can someone tell me, how could I check the size limit of an email message. So, if all attachements together exceeded the limit, I could send them in more messages. And lets say that each attachement is smaller than limit size.

Im using python 2.7 (email, smtplib modules).

Any suggestions, samples, links.. would be appreciated.

like image 317
Ales Kancilija Avatar asked May 18 '11 06:05

Ales Kancilija


1 Answers

Ok, I found that out :)

import smtplib    
smtp = smtplib.SMTP('server.name')    
smtp.ehlo()    
max_limit_in_bytes = int( smtp.esmtp_features['size'] )

This returns size limit (in bytes) of entire email (with header, subject, message text...).

like image 199
Ales Kancilija Avatar answered Oct 04 '22 02:10

Ales Kancilija