Skip to content

A comprehensive SMTP (Simple Mail Transfer Protocol) mail server implementation using Python's smtplib and Flask. This project provides a fully functional email communication system with user authentication, email composition, inbox management, mark emails as important and reply functionality.

Notifications You must be signed in to change notification settings

MudasirNaeem1/SMTP-Server-Python-smtplib-flask

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“§ SMTP Mail Server Implementation (Using smtplib and flask)

SMTP Python Flask SQLite Status

πŸ” About

A comprehensive SMTP (Simple Mail Transfer Protocol) mail server implementation using Python's smtplib and Flask. This project provides a fully functional email communication system with user authentication, email composition, inbox management, and reply functionality. Built with modern web technologies for seamless email handling in controlled environments.


🎯 Motivation

Why Build an SMTP Server?

The motivation behind this project is to create an efficient SMTP server that can send and receive emails in a controlled and reliable manner. This enables scalable email communication solutions for various applications requiring simple email transmission.

graph TD
    A[Email Client] --> B[SMTP Server]
    B --> C[Email Processing]
    C --> D[Database Storage]
    C --> E[Email Delivery]
    E --> F[Recipient Inbox]
    
    style A fill:#e1f5fe,stroke:#0277bd,stroke-width:2px
    style B fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px
    style F fill:#e8f5e8,stroke:#388e3c,stroke-width:2px
Loading

SMTP Server Architecture Overview


πŸš€ Key Features

Feature Description Status
πŸ“¨ Email Handling Process and store incoming emails in SQLite database βœ… Implemented
πŸ” User Authentication Secure login system with duplicate email prevention βœ… Implemented
πŸ“ Email Composition Rich email composition with subject and body βœ… Implemented
πŸ“¬ Inbox Management View received emails with sender details βœ… Implemented
πŸ“€ Sent Box Track all sent emails with timestamps βœ… Implemented
πŸ’¬ Reply Functionality Reply to received emails seamlessly βœ… Implemented
⭐ Mark Important Flag important emails for easy access βœ… Implemented
πŸ—‘οΈ Delete Emails Remove unwanted emails from inbox/sentbox βœ… Implemented
πŸ“Š Message Parsing Handle multipart messages and extract content βœ… Implemented
πŸ” Error Handling Comprehensive logging and error management βœ… Implemented

πŸ› οΈ Technology Stack

graph TD
    A[Frontend] --> B[HTML/CSS/JavaScript]
    A --> C[Bootstrap UI]
    
    D[Backend] --> E[Python 3.x]
    D --> F[Flask Framework]
    D --> G[smtplib]
    D --> H[aiosmtpd]
    
    I[Database] --> J[SQLite]
    
    K[Libraries] --> L[email module]
    K --> M[sqlite3]
    K --> N[logging]
    
    style A fill:#ff9800,color:#fff
    style D fill:#2196f3,color:#fff
    style I fill:#4caf50,color:#fff
    style K fill:#9c27b0,color:#fff
Loading

Complete Technology Stack

πŸ”§ Core Technologies

🐍 Backend Technologies

  • Python 3.x: Primary programming language
  • Flask: Web framework for creating the user interface
  • smtplib: Core SMTP functionality for sending emails
  • aiosmtpd: Asynchronous SMTP server implementation
  • SQLite: Lightweight database for email storage

🎨 Frontend Technologies

  • HTML5/CSS3: Structure and styling
  • Bootstrap: Responsive UI framework
  • JavaScript: Interactive functionality

🎬 System Workflow

sequenceDiagram
    participant U as User
    participant F as Flask App
    participant S as SMTP Server
    participant D as Database
    participant R as Recipient
    
    U->>F: 1. User Signup/Login
    F->>D: 2. Validate Credentials
    D-->>F: 3. Authentication Success
    
    U->>F: 4. Compose Email
    F->>S: 5. Send Email Request
    S->>R: 6. Deliver Email
    S->>D: 7. Store in Sent Box
    
    R->>F: 8. Receive Email
    F->>D: 9. Store in Inbox
    D-->>F: 10. Update Database
    
    Note over U,R: Email Successfully Exchanged
Loading

Email Communication Flow


πŸ” Screenshots & Demo

πŸ” User Authentication

Signup Process

First Signup Accounts to send mail from one account/Gmail to other.

Signup

Secure user registration with duplicate email prevention

πŸ“§ Email Composition

Compose Email Interface

After logged in, do compose an email on "mudasirnaeem000@gmail.com" Gmail account and sent it to "maisumabbas13@gmail.com"

Compose

Clean and intuitive email composition interface

πŸ” Inbox Management

Email Inbox

Email has successfully been sent to "maisumabbas13@gmail.com" and recieved in inbox folder as well. Sent messages has also saved in sentbox.

Inbox

Organized inbox with sender details and timestamps

πŸ’¬ Reply Functionality

Email Reply

We can do a reply as well. Reply emails will sent to the senders mails and sender can review receiver's reply.

Reply

Seamless email reply with thread continuity

Reply email has been send to sender's mail, and sender also recieved their reply in inbox folder.

⭐ Important Emails

Email Mark as Important

We can delete any email from inbox or sendbox, that may not relevant for us.

Delete

We also can mark any email from inbox as important.

Important

Flag important emails for quick access


πŸš€ Getting Started

πŸ“‹ Prerequisites

System Requirements

  • Python 3.x installed
  • pip package manager
  • Local machine for testing

πŸ“¦ Required Packages

Flask==2.3.3
aiosmtpd==1.4.4
sqlite3 (built-in)
smtplib (built-in)
email (built-in)
logging (built-in)

πŸ’‘ Usage Guide

1️⃣ Account Setup

  • Navigate to signup page
  • Create account with unique email
  • Login with credentials

2️⃣ Sending Emails

  • Click "Compose" button
  • Fill recipient, subject, and message
  • Click "Send" to deliver email

3️⃣ Managing Inbox

  • View received emails in inbox
  • Mark important emails with star
  • Reply to emails directly
  • Delete unwanted emails

4️⃣ Tracking Sent Emails

  • Access sent box to view outgoing emails
  • Check delivery status
  • Manage sent email history

πŸ”’ Security Features

Security Aspect Implementation Benefit
πŸ” User Authentication Login/Signup system Prevents unauthorized access
🚫 Duplicate Prevention Email uniqueness check Maintains data integrity
πŸ“ Input Validation Form validation Prevents malicious inputs
πŸ” Error Handling Comprehensive logging Tracks system issues
πŸ’Ύ Data Storage SQLite database Secure local storage

πŸ“Š Database Schema

erDiagram
    USERS {
        int id PK
        string email UK
        string password
        datetime created_at
    }
    
    EMAILS {
        int id PK
        string sender FK
        string recipient FK
        string subject
        text body
        datetime timestamp
        boolean is_important
        string status
    }
    
    USERS ||--o{ EMAILS : sends
    USERS ||--o{ EMAILS : receives
Loading

Database Relationship Diagram


🎯 Project Scope & Modules

πŸ” Core Modules

πŸ“§ Email Processing Module

  • Handle incoming/outgoing emails
  • Parse email headers and content
  • Store emails in database
  • Manage email threading

πŸ” Authentication Module

  • User registration and login
  • Password validation
  • Session management
  • Duplicate email prevention

πŸ’Ύ Database Module

  • SQLite database operations
  • Email storage and retrieval
  • User data management
  • Query optimization

🌐 Web Interface Module

  • Flask-based web application
  • Responsive UI design
  • AJAX operations
  • User-friendly navigation

πŸ“ˆ Development Timeline

gantt
    title SMTP Mail Server Development Timeline
    dateFormat  YYYY-MM-DD
    section Phase 1
    Research & Setup     :done, phase1, 2025-02-21, 2025-03-08
    section Phase 2
    Core Development     :done, phase2, 2025-03-09, 2025-03-20
    section Phase 3
    Database Integration :done, phase3, 2025-03-21, 2025-04-10
    section Phase 4
    Testing & Debugging  :done, phase4, 2025-04-11, 2025-04-22
    section Phase 5
    Documentation        :done, phase5, 2025-04-23, 2025-05-05
Loading

7-Week Development Schedule

πŸ“… Week-by-Week Breakdown

Week Tasks Responsibility
Week 1-2 Research & Environment Setup Both Members
Week 3 Email Processing & Server Setup Mudasir
Week 4 Database Design & Integration Maisum Abbas
Week 5-6 Testing & Optimization Both Members
Week 7 Documentation & Submission Both Members

πŸ”§ Testing & Quality Assurance

βœ… Test Categories

πŸ” Functional Testing

  • Email sending/receiving functionality
  • User authentication workflow
  • Database operations
  • Reply and forward features

πŸ›‘οΈ Security Testing

  • Input validation
  • SQL injection prevention
  • Authentication bypass attempts
  • Data encryption verification

⚑ Performance Testing

  • Email processing speed
  • Database query optimization
  • Memory usage monitoring
  • Concurrent user handling

🎯 Future Enhancements

mindmap
  root((Future Features))
    Attachments
      File Upload
      Image Support
      Document Sharing
    Security
      TLS Encryption
      Two-Factor Auth
      Spam Filtering
    UI/UX
      Mobile App
      Dark Theme
      Rich Text Editor
    Integration
      API Endpoints
      Third-party Services
      Cloud Storage
Loading

Planned Future Enhancements


πŸ‘₯ Team Members

Name Roll Number Responsibilities
Maisum Abbas 22K-4129 Flask Integration & Component Integration
Mudasir 22K-8732 SMTP Server Implementation & Email Handling

πŸ“š References & Documentation

πŸ“– Official Documentation

πŸ”§ Technical References

πŸŽ“ Educational Resources


πŸ”§ System Requirements

πŸ’» Hardware Requirements

  • Network: Internet connection for testing

πŸ–₯️ Software Requirements

  • Operating System: Windows 10/11, macOS, or Linux
  • Python: Version 3.7 or higher
  • Browser: Chrome, Firefox, Safari, or Edge
  • IDE: PyCharm, VS Code, or any text editor

πŸ“ž Contact & Support

Need Help? Let's Connect! 🌟

LinkedIn - Mudasir GitHub Email


πŸ’¬ Get In Touch

πŸ“§ Email Support: mudasirnaeem000@gmail.com
πŸŽ“ Institution: National University of Computer & Emerging Sciences
πŸ“ Location: Karachi, Pakistan

Found this project helpful? ⭐ Star the repository!
Have suggestions? πŸ’­ Feel free to discuss!
Want to collaborate? Let's connect!

Visitor Count


** Thank you for exploring our SMTP Mail Server project! **

About

A comprehensive SMTP (Simple Mail Transfer Protocol) mail server implementation using Python's smtplib and Flask. This project provides a fully functional email communication system with user authentication, email composition, inbox management, mark emails as important and reply functionality.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published