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

fix: don't let bcc recipients end up in 'to'. #22

Merged
merged 2 commits into from
Nov 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
5 changes: 4 additions & 1 deletion 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 @@ -26,7 +27,9 @@ def test_send_simple_message(self):
self.assertEqual(auth, ('api', b'testtesttest'))
# self.assertEqual(files, [])
self.assertEqual(data['from'], message.sender)
self.assertEqual(data['to'], set(message.recipients))
self.assertEqual(data['to'], message.recipients)
self.assertEqual(data['bcc'], message.bcc)
self.assertEqual(data['cc'], [])
self.assertEqual(data['subject'], message.subject)
self.assertEqual(data['text'], message.body)

Expand Down