Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
cannot send email with only bcc #14
message = Message(subject='test', body='this is a test', bcc=['firstname.lastname@example.org']) mailer.send(message) transaction.commit()
added a commit
Mar 15, 2012
The tests for cc-only and bcc-only worked under Python 2.6 but failed under Python 3.2 on rpatterson's master. Instead of fixing it, I just caused pyramid_mailer to raise a more descriptive error message saying:
raise InvalidMessage("Must have at least one direct recipient " "even if cc or bcc set")
We can revisit this later, I just couldn't figure out how to make it work under 3.2.
When I run tox against 95ff3e7, your first commit on top of my master, I see the failures in all envs. When I run tox against d2c6adf, my last change I see only an unrelated failure under jython (which I missed before, sorry). So I'm not seeing a 3.2 specific failure.
But reading your comment and commit logs more carefully, it seems like you want pyramid_mailer to enforce a prohibition against cc/bcc only messages so I guess I just shouldn't have gone off and implemented what mmerickel requested without discussion. Oops, sorry. :-)
No I don't want to enforce against it. I just couldn't figure out the failure I see.
When I comment out the check I added in message.py:
And add this test to tests.TestMessage
def test_cc_without_recipients_2(self): from pyramid_mailer.message import Message msg = Message(subject="testing", sender="email@example.com", body="testing", cc=["firstname.lastname@example.org"]) response = msg.get_response() self.assertTrue("Cc: email@example.com" in str(response))
This is the exception I get on my system under Python 3.2:
It doesn't happen on Python 2.6 or 2.7. I noticed while PDB stepping through it that the "To" header is the empty string. I suspect that may be why but I didn't chase it down and punted by disallowing it.
Hmm, I couldn't build build 3.2 with ssl support, I think because of http://bugs.python.org/issue12012. Without ssl, the imports in the tests are broken. So I manually applied the patch that fixes that bug:
Then I was able to reproduce the issue and commit a workaround that skips headers that would be empty strings which seems appropriate anyways.