diff --git a/pyramid_mailer/message.py b/pyramid_mailer/message.py index 3f97432..d1fb902 100644 --- a/pyramid_mailer/message.py +++ b/pyramid_mailer/message.py @@ -139,10 +139,6 @@ def validate(self): if not (self.recipients or self.cc or self.bcc): raise InvalidMessage("No recipients have been added") - if (self.cc or self.bcc) and not self.recipients: - raise InvalidMessage("Must have at least one direct recipient " - "even if cc or bcc set") - if not self.body and not self.html: raise InvalidMessage("No body has been set") diff --git a/pyramid_mailer/tests.py b/pyramid_mailer/tests.py index a148a1d..2c56241 100644 --- a/pyramid_mailer/tests.py +++ b/pyramid_mailer/tests.py @@ -168,8 +168,22 @@ def test_cc_without_recipients(self): body="testing", cc=["tosomeoneelse@example.com"]) mailer = Mailer() - from pyramid_mailer.exceptions import InvalidMessage - self.assertRaises(InvalidMessage, mailer.send, msg) + msgid = mailer.send(msg) + response = msg.get_response() + + self.assertTrue("Cc: tosomeoneelse@example.com" in str(response)) + self.assertTrue(msgid) + + def test_cc_without_recipients_2(self): + + from pyramid_mailer.message import Message + + msg = Message(subject="testing", + sender="sender@example.com", + body="testing", + cc=["tosomeoneelse@example.com"]) + response = msg.get_response() + self.assertTrue("Cc: tosomeoneelse@example.com" in str(response)) def test_bcc_without_recipients(self): @@ -181,8 +195,11 @@ def test_bcc_without_recipients(self): body="testing", bcc=["tosomeoneelse@example.com"]) mailer = Mailer() - from pyramid_mailer.exceptions import InvalidMessage - self.assertRaises(InvalidMessage, mailer.send, msg) + msgid = mailer.send(msg) + response = msg.get_response() + + self.assertFalse("Bcc: tosomeoneelse@example.com" in str(response)) + self.assertTrue(msgid) def test_attach(self):