# Codevra Mail — Real IMAP, SMTP, DNS (MX / SPF / DKIM / DMARC) & cPanel Guide

Codevra Mail does **not** simulate email in MySQL—it connects directly to your real cPanel mail server via authenticated **IMAP** (receiving) and **SMTP** (sending).

## 1. Create `@codevra.in` Mailboxes in cPanel
1. Go to **cPanel -> Email -> Email Accounts -> Create**.
2. Create company accounts such as `admin@codevra.in`, `hr@codevra.in`, `support@codevra.in`, `noreply@codevra.in`, and individual employee accounts (`name@codevra.in`).
3. Each employee signs into `https://mail.codevra.in`, opens **Mail -> IMAP / SMTP Settings**, and enters their `@codevra.in` mailbox password. Codevra Workspace encrypts the password using AES-256-GCM (`app_key`) before storing it in `mail_accounts`.

## 2. Standard cPanel Mail Server Settings
| Protocol | Hostname | Port | Encryption | Auth |
|---|---|---|---|---|
| **IMAP (Incoming)** | `mail.codevra.in` | `993` | SSL/TLS | Full `@codevra.in` email + mailbox password |
| **SMTP (Outgoing)** | `mail.codevra.in` | `465` (or `587`) | SSL (465) / STARTTLS (587) | AUTH LOGIN |

## 3. Mandatory DNS Records (cPanel -> Zone Editor)
Configure these records for `codevra.in` so outgoing emails land in recipients' inboxes rather than Spam:

- **A Record (Mail Subdomain)**:
  - Name: `mail.codevra.in.` | Type: `A` | Value: `<YOUR_CPANEL_SERVER_IP>`
- **MX Record (Inbound Mail Routing)**:
  - Name: `codevra.in.` | Priority: `0` | Destination: `mail.codevra.in.`
- **SPF Record (TXT)**:
  - Name: `codevra.in.` | Type: `TXT` | Value: `v=spf1 +a +mx +ip4:<YOUR_CPANEL_SERVER_IP> ~all`
- **DKIM Record**:
  - Open **cPanel -> Email -> Email Deliverability -> Manage (`codevra.in`)** and click **Install The Suggested Record** for DKIM (`default._domainkey.codevra.in`).
- **DMARC Record (TXT)**:
  - Name: `_dmarc.codevra.in.` | Type: `TXT` | Value: `v=DMARC1; p=quarantine; rua=mailto:admin@codevra.in; pct=100; adkim=s; aspf=s`

## 4. Optional: cPanel UAPI Mailbox Provisioning
To enable automated cPanel mailbox creation later, generate an API Token in **cPanel -> Security -> Manage API Tokens** and add it to `private_codevra/config.php` under `cpanel_uapi`. Leave `enabled => false` if you prefer creating mailboxes manually in cPanel.
