Open r-pluss opened 7 years ago
Hi, r-pluss! Sorry for being so late with response.
I definitely want to fail fast when email body is empty. It should protect from sending empty (i.e. broken) emails to people on mass sending.
Sending email with empty body is rare case. May be there should be parameter to allow empty body in Message constructor
Please see this very short and simple gist for an example.
I believe the exception is the result of the _build_html_part method of message.py (currently starting at line 265).
As Python will evaluate a zero-length string as False in a conditional context, the subsequent calls to SafeMIMEText and set_charset are silently skipped and a None is returned.
As the RFC defines an email message body as optional, I believe a zero-length message should be allowed by this library. For my own use-case, I discovered this when setting up some automated reports to be emailed by a CI server as attachments, hence only needing a subject line and the attachments, no message body. Was very simple to workaround by adding a short message, but would like to see this be in closer compliance to the spec.
Slightly off-topic - Great job on this module, it's been extremely simple and enjoyable to work with.