开发者

Check the email message size limit with Python

开发者 https://www.devze.com 2023-03-06 12:27 出处:网络
Can someone tell me, how could I check the size limit of an email message. So, if all attachements together exceeded the limit, I cou开发者_高级运维ld send them in more messages. And lets say that eac

Can someone tell me, how could I check the size limit of an email message. So, if all attachements together exceeded the limit, I cou开发者_高级运维ld 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.


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...).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号