A fully automated, production-ready email delivery workflow integrating:
- Oracle Database
- Oracle Triggers & Scheduler Jobs
- Python FastAPI Microservice
- Zoho Mail API (OAuth2)
This system automatically sends emails when a new record is inserted into the Oracle table. If an email fails, a scheduler job retries it automatically every 5 minutes.
Triggered instantly after an INSERT operation in Oracle.
A DBMS Scheduler job reprocesses FAILED or PENDING emails every 5 minutes.
Receives email_id, fetches data from Oracle, and sends email using Zoho Mail API.
- HTML content
- CC / BCC
- File attachments (path-based)
- OAuth2 Zoho authentication
Updates:
LAST_UPDATELAST_UPDATE_DATE
automated-email-notification-system/
β
βββ fastapi/
β βββ app.py
β βββ db.py
β βββ email_sender.py
β βββ .env.example
β βββ requirements.txt
β βββ README.md
β
βββ sql/
β βββ email_notification.sql
β βββ email_notificaion_seq.sql
β βββ email_notification_trigger.sql
β βββ email_notification_procedure.sql
β βββ scheduler_pending_emails.sql
β βββ README.md
β
βββ apex/
β βββ (APEX REST or documentation if any)
β
βββ .env.example
βββ .gitignore
βββ README.md β this file
(no subgraph, no unsupported syntax)
flowchart TD
A[Insert into EMAIL_NOTIFICATION] --> B[BEFORE INSERT Trigger - Assign ID]
B --> C[AFTER INSERT Trigger - Call SEND_EMAIL_REQUEST]
C --> D[FastAPI /send-email Endpoint]
D --> E[Fetch Email Row from Oracle DB]
E --> F[Send Email via Zoho Mail API]
F --> G[Update LAST_UPDATE = 'SENT']
G --> H[Done]
%% Retry Logic
X[Scheduler Job - Every 5 min] --> Y[Find UNSENT or FAILED Emails]
Y --> D
β This diagram renders perfectly on GitHub.
INSERT INTO EMAIL_NOTIFICATION (EMAIL, SUBJECT, MESSAGE)
VALUES ('test@example.com','Hello','<h2>Welcome</h2>');SEND_EMAIL_REQUEST(:NEW.ID);{ "email_id": 12 }LAST_UPDATE = 'SENT'
LAST_UPDATE = 'FAILED'
sql/email_notification.sql
sql/email_notificaion_seq.sql
sql/email_notification_trigger.sql
sql/email_notification_procedure.sql
sql/scheduler_pending_emails.sql
Start API:
uvicorn app:app --host 0.0.0.0 --port 8000| Method | URL | Description |
|---|---|---|
| GET | / |
Health check |
| POST | /send-email |
Sends email using email_id |
.env.example (root or fastapi folder):
ORACLE_USER=
ORACLE_PASSWORD=
ORACLE_DSN=
ZOHO_CLIENT_ID=
ZOHO_CLIENT_SECRET=
ZOHO_REFRESH_TOKEN=
ZOHO_ACCOUNT_ID=
ZOHO_FROM_ADDRESS=
Developed by Nayan Das Enterprise-grade automation with Oracle Database + FastAPI + Zoho API.