Skip to content

Commit

Permalink
fix: don't let bcc recipients end up in 'to'.
Browse files Browse the repository at this point in the history
  • Loading branch information
kvdb committed Jul 19, 2018
1 parent 3d908f7 commit 2652e90
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion flask_mailgun/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def send(self, message, envelope_from=None):
:param envelope_from: Email address to be used in MAIL FROM command.
"""
mesage_data = {'from': envelope_from or message.sender,
'to': message.send_to,
'to': message.recipients,
'subject': message.subject,
"cc": message.cc,
"bcc": message.bcc,
Expand Down
4 changes: 0 additions & 4 deletions flask_mailgun/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,6 @@ def __init__(self, subject='',
self.rcpt_options = rcpt_options or []
self.attachments = attachments or []

@property
def send_to(self):
return set(self.recipients) | set(self.bcc or ()) | set(self.cc or ())

@property
def html(self):
return self.alts.get('html')
Expand Down
3 changes: 3 additions & 0 deletions tests/test_send.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def test_send_simple_message(self):
message = Message(subject="Hello",
sender="from@example.com",
recipients=["u1@example.com", "u2@example.com"],
bcc=["foo@bar.com"],
body="Testing some Mailgun awesomness!")
self.mailgun.send(message)
self.assertTrue(self.mock_post.called)
Expand All @@ -27,6 +28,8 @@ def test_send_simple_message(self):
# self.assertEqual(files, [])
self.assertEqual(data['from'], message.sender)
self.assertEqual(data['to'], set(message.recipients))
self.assertEqual(data['bcc'], set(message.bcc))
self.assertEqual(data['cc'], set())
self.assertEqual(data['subject'], message.subject)
self.assertEqual(data['text'], message.body)

Expand Down

0 comments on commit 2652e90

Please sign in to comment.