From 95ff3e71a34dbbee919b2939620a54733a40648e Mon Sep 17 00:00:00 2001 From: Chris McDonough Date: Tue, 20 Mar 2012 01:24:28 -0400 Subject: [PATCH] canonize inability to send messages without one direct recipient --- pyramid_mailer/message.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pyramid_mailer/message.py b/pyramid_mailer/message.py index 6428856..b24907f 100644 --- a/pyramid_mailer/message.py +++ b/pyramid_mailer/message.py @@ -139,6 +139,10 @@ 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")