diff --git a/onboarding/templates/onboarding/candidates.html b/onboarding/templates/onboarding/candidates.html index d67d96eb1..ab72b9653 100644 --- a/onboarding/templates/onboarding/candidates.html +++ b/onboarding/templates/onboarding/candidates.html @@ -85,6 +85,12 @@ href="{% url 'rec-candidate-update' candidate.id %}?onboarding=True" > + + + + + + + Horilla News Letter Design + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+ + + View in browser +
+
+ +
+ Hello {{ instance.name }}, Congratulations on your selection! +
+

Your dedication is valued, and we wish you continued success. If you have questions or need assistance, feel free to ask. Best wishes for your journey! Kindly complete your profile when convenient.

+
+ Complete Profile +
+ This mail was sent you because your email has been enrolled as an candidate at {{ instance.recruitment_id.company_id.company }}.
+ Don't want to receive mails like these anymore? + Unsubscribe here. +
© 2023 Horilla, Inc.
+
+ + diff --git a/onboarding/views.py b/onboarding/views.py index ed368a99b..d0c1599ef 100644 --- a/onboarding/views.py +++ b/onboarding/views.py @@ -10,8 +10,11 @@ actions to handle the request, process data, and generate a response. This module is part of the recruitment project and is intended to provide the main entry points for interacting with the application's functionality. """ + from urllib.parse import parse_qs import json, contextlib, random, secrets +from django.core.mail import EmailMessage +from django.template.loader import render_to_string from django.core.mail import send_mail from django.contrib.auth.models import User from django.utils.translation import gettext as __ @@ -543,6 +546,8 @@ def email_send(request): """ if request.method != "POST": return JsonResponse("", safe=False) + host = request.get_host() + protocol = "https" if request.is_secure() else "http" candidates = request.POST.get("candidates") json_list = json.loads(candidates) if len(json_list) <= 0: @@ -561,13 +566,26 @@ def email_send(request): new_portal.save() else: OnboardingPortal(candidate_id=candidate, token=token).save() - send_mail( - "Onboarding Portal", - f"{request.get_host()}/onboarding/user-creation/{token}", - "from@example.com", - [candidate.email], - fail_silently=False, + html_message = render_to_string( + "onboarding/mail_templates/default.html", + { + "portal": f"{protocol}://{host}/onboarding/user-creation/{token}", + "instance": candidate, + "host": host, + "protocol": protocol, + }, ) + email = EmailMessage( + f"Hello {candidate.name}, Congratulations on your selection!", + html_message, + settings.EMAIL_HOST_USER, + [candidate.email], + ) + email.content_subtype = "html" + try: + email.send() + except: + messages.error(request,f"Mail not send to {candidate.name}") candidate.start_onboard = True candidate.save() return JsonResponse({"message": _("Email send successfully"), "tags": "success"})