Skip to content
Open
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
6 changes: 4 additions & 2 deletions sendgrid_backend/mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,11 +310,13 @@ def _build_sg_personalization(

if not personalization.ccs:
for addr in msg.cc:
personalization.add_cc(Email(*self._parse_email_address(addr)))
if addr:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a warning log if addr == ""?

personalization.add_cc(Email(*self._parse_email_address(addr)))

if not personalization.bccs:
for addr in msg.bcc:
personalization.add_bcc(Email(*self._parse_email_address(addr)))
if addr:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

personalization.add_bcc(Email(*self._parse_email_address(addr)))

if not personalization.custom_args:
for k, v in getattr(msg, "custom_args", {}).items():
Expand Down
6 changes: 4 additions & 2 deletions test/test_mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ def test_EmailMessage(self):
body="Hello, World!",
from_email="Sam Smith <sam.smith@example.com>",
to=["John Doe <john.doe@example.com>", "jane.doe@example.com"],
cc=["Stephanie Smith <stephanie.smith@example.com>"],
bcc=["Sarah Smith <sarah.smith@example.com>"],
# Include blank address to confirm that it's ignored
cc=["Stephanie Smith <stephanie.smith@example.com>", ""],
# Include blank address to confirm that it's ignored
bcc=["Sarah Smith <sarah.smith@example.com>", ""],
reply_to=["Sam Smith <sam.smith@example.com>"],
)

Expand Down