This is a Django-based RESTful API for sending emails. It allows you to send emails by making POST requests to the API with the required data in JSON format.
- Docker
- Docker Compose
-
Clone the repository:
git clone [email protected]:datumbrain/django-rest-emailapi.git
-
Navigate to the project directory:
cd django-rest-emailapi
Open the project in your code editior.
-
Create a virtual environment in the project root directory and activate it.
python3 -m venv env source env/bin/activate
-
In the project navigate to settings.py file (project path/emailapi/settings.py)and set the values of
SECRET_KEY
,EMAIL_HOST_USER
andEMAIL_HOST_PASSWORD
with your own email credentials. -
Run the Docker containers:
docker-compose up -d
-
Visit http://0.0.0.0:8000/email in your web browser to access the email API.
This endpoint sends an email with the provided data in JSON format. Required fields: to_email, subject, body, from_email.
On success, the API returns a 200 OK response with the message "Email sent".
On failure, the API returns a 400 Bad Request response with the error message or a 500 with a message "Email sending failed".