# implementation_plan.md

# Vexib Mail System - Virtual Mailbox Migration Plan

## Goal

Replace Linux user accounts with database-driven virtual mailboxes.

Benefits:

* Unlimited mailboxes
* Multiple domains
* No Linux accounts required
* Easier backups
* Easier migrations
* Future self-service administration

---

# Phase 1 – Existing System

Current architecture:

```
Thunderbird
     ↓
mail.vexib.co.uk
(Postfix + Dovecot)
     ↓
SMTP2GO
     ↓
Internet
```

Mailboxes are Linux users.

Status:

COMPLETE

---

# Phase 2 – Introduce Virtual Domains

Example domains:

```
vexib.co.uk
albumdb.vexib.co.uk
progressvinyl.co.uk
classicvinyl.co.uk
```

---

# Phase 3 – Database Design

Tables:

## virtual_domains

```
id
domain_name
active
```

## virtual_users

```
id
domain_id
email
password_hash
quota_mb
active
```

## virtual_aliases

```
id
source_email
destination_email
active
```

---

# Phase 4 – Mail Storage

Move to:

```
/var/mail/vhosts/
```

Structure:

```
/var/mail/vhosts/vexib.co.uk/phil/
/var/mail/vhosts/vexib.co.uk/george/
/var/mail/vhosts/albumdb.vexib.co.uk/info/
/var/mail/vhosts/progressvinyl.co.uk/support/
```

---

# Phase 5 – Postfix MySQL Integration

Configure Postfix to query MySQL for:

* Domains
* Users
* Aliases

---

# Phase 6 – Dovecot SQL Authentication

Dovecot authenticates users directly from MySQL.

Linux accounts are no longer required.

---

# Phase 7 – Administration Tools

Create PHP administration pages:

## Domains

* Add domain
* Disable domain

## Mailboxes

* Add mailbox
* Delete mailbox
* Change password
* Set quota

## Aliases

* Create aliases
* Forward addresses

---

# Phase 8 – Backup and Restore

Include:

* MySQL database
* Mail directories
* Configuration files

Support full disaster recovery.

---

# Phase 9 – Customer Self-Service

Allow hosted customers to manage:

* Mailboxes
* Passwords
* Aliases
* Forwarders

through a web interface.

---

# Long-Term Goal

Provide a multi-domain mail platform suitable for:

* Vexib
* AlbumDB
* Hosted customer domains
* Future SaaS projects

while retaining SMTP2GO as the outbound relay.
