A simple client-server based email simulation system built using Java, demonstrating TCP/IP socket programming, Object-Oriented Programming (OOP), Dependency Injection, and Database operations (SQLite). The project allows users to register, login, send emails, and optionally generate email bodies using a Python ML model.
- Send and receive emails using a TCP/IP-based custom protocol.
- User registration and login stored in an SQLite database.
- Inbox and Sent email management using database tables.
- Automatic email body generation using a Python ML model based on subject keywords.
- Modular code structure with OOP principles and dependency injection.
| Technology | Purpose |
|---|---|
| Java | Core programming language |
| TCP/IP Sockets | Network communication between client and server |
| SQLite | Database to store user credentials and emails |
| Python (ML) | Generates email body based on subject |
| OOP Concepts | Encapsulation, modular design, class-based structure |
| Dependency Injection | Decoupling email server from database instance |
SimpleEmailServer/
│
├
├── Main.java # Client CLI for registration, login, and sending emails
│── SimpleEmailServer.java # Handles sending emails via TCP socket and calls Python ML for email body
│── User.java # User model
│── Database.java # SQLite DB handler
│── DatabaseCopy.java # Wrapper for Database with DI
│── EmailReceiverServer.java # TCP Server to receive emails and store them
│
├── ml_models/ # Python ML model for email body generation
│ ├── predict_email.py
│ ├── email_vectorizer.pkl
| ├── train_email_model.py
│ └── email_nn_model.pkl
│
├── users.db # SQLite database storing credentials & emails
├── README.md # Project documentation
└── ...
-
Registration
- User registers with name, email, and password.
- Credentials are stored in the SQLite database.
-
Sending an Email
- Client collects
from,to,subject, and optionally generates body using Python ML. - If ML body is not available or user rejects it, client can enter a custom body.
- Sends data using a TCP socket to the server.
- Email is inserted into Sent table and delivered to the receiver.
- Client collects
-
Receiving an Email
- Server listens on port 5000.
- Accepts email data from client and stores it in the Inbox table of the database.
-
Dependency Injection
SimpleEmailServerreceives aDatabaseCopyinstance via its constructor.- Promotes loose coupling and easier testing.
-
ML Email Body Generation
- Python script
ml_models/predict_email.pyuses a pre-trained model to generate a suggested email body based on subject keywords. - User can accept or override the generated email body.
- Python script
- Java JDK 8 or higher installed.
- VS Code or any Java IDE.
- SQLite (optional, to inspect the database).
- Python 3.x with
scikit-learnandpickleinstalled (for ML model).
javac src/*.javajava -cp <path> EmailReceiverServerjava -cp <path> MainQuerying the Inbox table after sending an email:
| mail_from | name | subject | message |
|---|---|---|---|
| Anjali | Nidhi | Greetings | Hi, hope you're doing well! |
| Anjali | John | Welcome | Welcome to our platform! |
- This is a simulation and does not send real emails over the internet.
- All data is stored in a local SQLite database.
- Demonstrates TCP/IP networking, OOP, Dependency Injection, and Python ML integration for generating email bodies.