Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error When Message Body Is A Zero-length String #82

Open
r-pluss opened this issue Feb 22, 2017 · 1 comment
Open

Error When Message Body Is A Zero-length String #82

r-pluss opened this issue Feb 22, 2017 · 1 comment

Comments

@r-pluss
Copy link

r-pluss commented Feb 22, 2017

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.

@lavr
Copy link
Owner

lavr commented Dec 13, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants