SSL Error when trying to send or recive emails

Hello every one hope you have a great day,

i was working on an e-commerce app and one feature is sending emails on every order update so i used my email for testing and this thing worked

EMAIL_BACKEND = “django.core.mail.backends.smtp.EmailBackend”

EMAIL_PORT = 587

EMAIL_USE_TLS = True

DEFAULT_FROM_EMAIL= os.getenv(“ADMIN_EMAIL”)

EMAIL_HOST = ‘smtp.gmail.com

EMAIL_HOST_USER = DEFAULT_FROM_EMAIL

here’s the email settings

and when i tried this project on a mono-repo to prepare for deployment i used docker and docker-compose

the issue is when i tried to build this on my local machine every thing worked well and nothin un expected happened

when i tried to build it on another machine using the same githup repo and the same docker files the emails can’t be sent and i got an error like this printed on the console

[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate in certificate chain (_ssl.c:1010)

i this only appears when the website is built on another laptop

Here’s the docker file if you are wondering

syntax=docker/dockerfile:1

FROM python:3.12-slim

# Prevents Python from writing .pyc files and enables unbuffered stdout/stderr

ENV PYTHONDONTWRITEBYTECODE=1 \

PYTHONUNBUFFERED=1

WORKDIR /app

# Install system dependencies for psycopg2

RUN apt-get update && \

apt-get install -y --no-install-recommends gcc libpq-dev && \\

rm -rf /var/lib/apt/lists/\*

# Install Python dependencies

COPY requirements.txt .

RUN pip install --no-cache-dir -r requirements.txt

# Copy project files

COPY . .

# Copy and prepare entrypoint script

COPY entrypoint.sh /entrypoint.sh

RUN sed -i ‘s/\r$//’ /entrypoint.sh && chmod +x /entrypoint.sh

# Create media directory

RUN mkdir -p /app/media

EXPOSE 8000

ENTRYPOINT [“/entrypoint.sh”]

i hope you might help me with this one because i was struggling with it since it’s my first production app and i want it to get ready for deployment

(When posting code, please enclose it between lines of three ``` backticks so it formats properly. The backticks must be on lines by themselves, with the code on the lines between them.)

Does that other machine connect through some sort of firewall or security proxy? This error sounds like something is messing with the attempt to create a secure connection to gmail. smtp.gmail.com doesn’t use a self-signed certificate, so either something is inserting one into the connection, or the root certificates available on that other machine are incomplete or outdated.

For some possible explanations and solutions, try pasting this into a search engine or AI: “certificate verify failed: self-signed certificate in certificate chain in docker built on one machine but not another, when connecting to smtp.gmail.com.” (That’s the important part of the error message plus a brief description of the symptoms. Mentioning smtp.gmail.com makes it clear you’re not trying to connect to some internal server where you might be using self-signed certificates.)