Skip to content

Conversation

@Viloetsisi
Copy link
Contributor

@Viloetsisi Viloetsisi commented Dec 3, 2025

Change Summary

This PR implements the full backend email functionality for Issue #31.
It introduces Django email configuration, a reusable email utility function, and updates the environment variable template.
The integration was validated successfully by sending real test emails inside the DevContainer.

Change Form

  • The pull request title has an issue number
    Includes: issue-31-Add_email_API_and_email_configurations

  • The change works by "Smoke testing" or quick testing
    A real email was successfully sent using send_simple_email() inside manage.py shell, confirming Gmail App Password setup works.

  • The change has tests
    NA — No automated email tests added due to time constraints and because email sending typically requires mocking external SMTP servers.

  • The change has documentation
    .env.example updated to include required email environment variables and developer instructions.

Other Information

  • Merge conflicts with settings.py (due to new S3 configuration from main) were resolved cleanly.
  • Installed django-storages[boto3] to support new S3 backend introduced in main.
  • Adjusted DevContainer .env database host to ensure backend starts correctly after merging latest main.
  • Email sending was confirmed to work with Gmail App Passwords and correct SMTP configuration.

Related issue

@Viloetsisi
Copy link
Contributor Author

Screenshot 2025-12-03 114801 Screenshot 2025-12-03 114743 Screenshot 2025-12-03 114714

@Viloetsisi Viloetsisi requested a review from ErikaKK December 3, 2025 04:00
@Viloetsisi Viloetsisi added the backend Task must have a back end issue label Dec 3, 2025
@ErikaKK ErikaKK requested a review from Copilot December 3, 2025 09:48
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR implements email functionality for Issue #31, adding Django email configuration, a reusable email utility function, and updating environment variable templates. The implementation supports SMTP email sending with configurable backends.

Key changes:

  • Email configuration added to Django settings with environment variable support
  • Reusable send_simple_email() utility function for sending emails
  • Comprehensive .env.example documentation for email setup with Gmail App Password guidance

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
server/requirements.txt Complete dependencies list for the project
server/api/settings.py Added email configuration section with SMTP settings and environment variable support
server/api/email_utils.py New utility module with send_simple_email() wrapper function for Django's send_mail
server/.env.example Updated with email configuration variables and developer setup instructions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@ErikaKK ErikaKK left a comment

Choose a reason for hiding this comment

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

I got a few questions, will talk tomorrow

Copy link
Contributor

Choose a reason for hiding this comment

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

please remove this. we are using poetry to manage dependencies

Copy link
Contributor

@ErikaKK ErikaKK left a comment

Choose a reason for hiding this comment

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

need a few changes, pls add html template for the email

EMAIL_HOST_PASSWORD=your_app_password_here

EMAIL_USE_TLS=True
DEFAULT_FROM_EMAIL="Bloom Notifications <your_email@example.com>"
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks like optional, so pls remove this, bc the title of the subject can tell it's bloom email

from typing import Iterable


def send_simple_email(
Copy link
Contributor

Choose a reason for hiding this comment

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

we'll have html content for the email message. I just added the design in figma:
image
image

pls update according to this

Wrapper for Django's send_mail using DEFAULT_FROM_EMAIL.
"""
if from_email is None:
from_email = settings.DEFAULT_FROM_EMAIL or settings.EMAIL_HOST_USER
Copy link
Contributor

Choose a reason for hiding this comment

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

please remove settings.DEFAULT_FROM_EMAIL or

EMAIL_USE_TLS = os.environ.get("EMAIL_USE_TLS", "True") == "True"
EMAIL_USE_SSL = os.environ.get("EMAIL_USE_SSL", "False") == "True"

DEFAULT_FROM_EMAIL = os.environ.get(
Copy link
Contributor

Choose a reason for hiding this comment

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

DEFAULT_FROM_EMAIL = os.environ.get("EMAIL_HOST_USER", "")

@Viloetsisi
Copy link
Contributor Author

Key changes:

  • Updated email_utils.py to support HTML templates and new wrapper functions.
  • Added two new templates (booking_confirmed.html, booking_cancelled.html) under api/templates/emails.
  • Updated Django TEMPLATES config to include api/templates.
  • Cleaned up env configuration by removing unused DEFAULT_FROM_EMAIL.

I have tested the updated email templates in the Django shell by rendering them directly with sample context data. This generated local HTML preview files, which match the expected design and display correctly as shown in the screenshots.

Screenshot 2025-12-08 151315 Screenshot 2025-12-08 151335 Screenshot 2025-12-08 151439 Screenshot 2025-12-08 151453

@Viloetsisi Viloetsisi requested a review from ErikaKK December 8, 2025 09:28
Copy link
Contributor

Choose a reason for hiding this comment

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

please don't hard code, think about using a function and pass the details. pls use the bloom logo that you can find in figma thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend Task must have a back end issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add email API and email configurations

3 participants