Skip to content

Commit

Permalink
feat: add bcc capability
Browse files Browse the repository at this point in the history
  • Loading branch information
johanseto committed Aug 18, 2023
1 parent a4f21df commit 9d029fa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,17 @@ def add_arguments(self, parser):
required=False,
help='Indicate specific payment notification to sent id'
)
parser.add_argument(
'--bcc',
nargs="+",
required=False,
help='Indicate secret bcc to send emails'
)
def handle(self, *args, **kwargs): # lint-amnesty, pylint: disable=too-many-statements
logger.info('----Processing payment notifications to send email-----')
start_time = datetime.now()
payment_notifications_ids = kwargs.get('payment_notifications_ids')
bcc = kwargs.get('bcc')
if payment_notifications_ids:
delivery_qs = PaymentNotification.objects.filter( # pylint: disable=no-member
id__in=payment_notifications_ids,
Expand Down
3 changes: 2 additions & 1 deletion eox_nelp/notifications/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ def send_email_multialternative(
recipient_emails=None,
from_email=None,
connection=None,
bcc=None,
):
"""
Function to send emails with plaintext msg and html msg.
Returns:
(int): Number of emails sent.
"""
logger.info("------Sending email with subject: %s -------", subject)
msg = EmailMultiAlternatives(subject, plaintext_msg, from_email, recipient_emails, connection=connection)
msg = EmailMultiAlternatives(subject, plaintext_msg, from_email, recipient_emails, connection=connection, bcc=bcc)
msg.attach_alternative(html_msg, "text/html")
return msg.send()

Expand Down

0 comments on commit 9d029fa

Please sign in to comment.