diff --git a/recruitment/email_service.py b/recruitment/email_service.py index 294c818..541b3ff 100644 --- a/recruitment/email_service.py +++ b/recruitment/email_service.py @@ -242,7 +242,7 @@ def send_bulk_email(subject, message, recipient_list, request=None, attachments= Send bulk email to multiple recipients with HTML support and attachments, supporting synchronous or asynchronous dispatch. """ - + # --- 1. Categorization and Custom Message Preparation (CORRECTED) --- agency_emails = [] @@ -303,10 +303,10 @@ def send_bulk_email(subject, message, recipient_list, request=None, attachments= job_id=job.id sender_user_id=request.user.id if request and hasattr(request, 'user') and request.user.is_authenticated else None - + # Loop through ALL final customized sends - - + + task_id = async_task( 'recruitment.tasks.send_bulk_email_task', subject, @@ -315,7 +315,6 @@ def send_bulk_email(subject, message, recipient_list, request=None, attachments= sender_user_id, job_id, hook='recruitment.tasks.email_success_hook', - ) task_ids.append(task_id) @@ -376,7 +375,7 @@ def send_bulk_email(subject, message, recipient_list, request=None, attachments= except Exception as e: logger.error(f"Failed to send email to {recipient}: {str(e)}", exc_info=True) - + # Send Emails - Pure Candidates for email in pure_candidate_emails: candidate_name = Application.objects.filter(email=email).first().first_name @@ -398,7 +397,7 @@ def send_bulk_email(subject, message, recipient_list, request=None, attachments= 'recipients_count': successful_sends, 'message': f'Email processing complete. {successful_sends} email(s) were sent successfully to {total_recipients} unique intended recipients.' } - + except Exception as e: error_msg = f"Failed to process bulk email send request: {str(e)}"