From 9260d121e57dcc52cf35d055508441c51441256a Mon Sep 17 00:00:00 2001 From: Gowtham Sai <66207607+gowtham3105@users.noreply.github.com> Date: Mon, 29 Aug 2022 23:07:15 +0530 Subject: [PATCH] Send email to cdc on new opening. --- CDC_Backend/APIs/companyViews.py | 2 +- CDC_Backend/APIs/constants.py | 2 ++ CDC_Backend/APIs/utils.py | 5 ++++- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CDC_Backend/APIs/companyViews.py b/CDC_Backend/APIs/companyViews.py index 3421b2f..6cca9be 100644 --- a/CDC_Backend/APIs/companyViews.py +++ b/CDC_Backend/APIs/companyViews.py @@ -279,7 +279,7 @@ def verifyEmail(request): "opening_type": PLACEMENT, "company_name": opening.company_name, } - sendEmail(opening.email, COMPANY_OPENING_SUBMITTED_TEMPLATE_SUBJECT.format(id=opening.id), data, + sendEmail([opening.email, CDC_MAIl_ADDRESS], COMPANY_OPENING_SUBMITTED_TEMPLATE_SUBJECT.format(id=opening.id), data, COMPANY_OPENING_SUBMITTED_TEMPLATE, attachment_jnf_respone) return Response({'action': "Verify Email", 'message': "Email Verified Successfully"}, diff --git a/CDC_Backend/APIs/constants.py b/CDC_Backend/APIs/constants.py index 576165e..35afd94 100644 --- a/CDC_Backend/APIs/constants.py +++ b/CDC_Backend/APIs/constants.py @@ -45,6 +45,8 @@ DEGREE_CHOICES = [ TOTAL_BRANCHES = 4 # Total No of Branches TOTAL_BATCHES = 5 # Total No of Batches +CDC_MAIl_ADDRESS = 'cdc@iitdh.ac.in' + # To be Configured Properly CLIENT_ID = os.environ.get('GOOGLE_OAUTH_CLIENT_ID') # Google Login Client ID diff --git a/CDC_Backend/APIs/utils.py b/CDC_Backend/APIs/utils.py index 50bfe9e..4913746 100644 --- a/CDC_Backend/APIs/utils.py +++ b/CDC_Backend/APIs/utils.py @@ -146,7 +146,10 @@ def sendEmail(email_to, subject, data, template, attachment_jnf_response=None): text_content = strip_tags(html_content) email_from = settings.EMAIL_HOST_USER - recipient_list = [str(email_to), ] + if type(email_to) is list: + recipient_list = [str(email) for email in email_to] + else: + recipient_list = [str(email_to), ] msg = EmailMultiAlternatives(subject, text_content, email_from, recipient_list) msg.attach_alternative(html_content, "text/html")