# Mail Server Settings - Quick Reference

**Server:** mail.mavrix.one (172.16.4.250 internal)  
**Date:** February 3, 2026

---

## SMTP Settings (Outgoing Mail)

**For System Emails** (password resets, OTP, notifications, etc.)

| Setting | Value |
|---------|-------|
| Host | 172.16.4.250 |
| Port | 587 |
| Encryption | TLS (STARTTLS) |
| Username | erp_system@mavrix.one |
| Password | xyz8468RPMerkuri123! |
| From Email | erp_system@mavrix.one |
| From Name | Mavrix1 |

**Configure at:** `/settings/email` (Admin only)

---

## IMAP Settings (Incoming Mail)

**For Personal Email Accounts** (reading emails in ERP)

| Setting | Value |
|---------|-------|
| Host | 172.16.4.250 |
| Port | 993 |
| Encryption | SSL |
| Username | your_email@mavrix.one |
| Password | your_email_password |

**Configure at:** `/settings/preferences` → Email tab (Per user)

---

## Database Configuration

All settings stored in `system_settings` table:

```sql
-- SMTP Settings
smtp_host: 172.16.4.250
smtp_port: 587
smtp_encryption: tls
smtp_username: erp_system@mavrix.one
smtp_password: xyz8468RPMerkuri123!
smtp_from_email: erp_system@mavrix.one
smtp_from_name: Mavrix1

-- IMAP Settings (defaults)
imap_host: 172.16.4.250
imap_port: 993
imap_encryption: ssl
```

---

## Valid Email Accounts

These mailboxes exist on the mail server:
- `erp_system@mavrix.one` - System account (SMTP sender)
- `rick@mavrix.one` - User account
- `info@mavrix.one` - General company email

**Note:** Email addresses in ERP database may not exist as actual mailboxes.

---

## Testing

### Test SMTP (Outgoing)
1. Via Settings Page:
   - Go to `/settings/email`
   - Click "Test Connection" button
   - Should see green success badge

2. Via Test Script:
   ```bash
   php public/test-email-simple.php
   ```

### Test IMAP (Incoming)
1. Via Preferences Page:
   - Go to `/settings/preferences` → Email tab
   - Fill in your email credentials
   - Click "Test Connection" button

---

## Network Details

**Mail Server:**
- Internal IP: 172.16.4.250 ✅ (accessible)
- External IP: 172.99.62.118 ❌ (firewall blocks external access)
- Hostname: mail.mavrix.one
- Software: Postfix (ESMTP Postcow)

**Ports:**
- SMTP: 587 (TLS/STARTTLS) ✅
- SMTPS: 465 (SSL) - not tested
- IMAP: 993 (SSL) ✅
- IMAPS: 143 (TLS) - not tested

**Important:** Use internal IP (172.16.4.250) for both SMTP and IMAP when on internal network.

---

## SSL Certificate Note

The mail server has an SSL certificate for `mail.mavrix.one`, but we're connecting via IP address `172.16.4.250`. 

**Solution:** SSL verification is disabled in code:
- `EmailService.php` - Line 54-60
- `SettingsController.php` (testSmtpConnection) - Line 1062-1069

This allows connection despite certificate CN mismatch.

---

## Quick Commands

```bash
# Check all mail settings
mysql -u rpmbbu -p'z8468RPMerkuri123!' brickwal_m1_ds -e \
"SELECT setting_key, setting_value FROM system_settings 
WHERE setting_key LIKE 'smtp%' OR setting_key LIKE 'imap%' 
ORDER BY setting_key"

# Test SMTP port
nc -zv 172.16.4.250 587

# Test IMAP port
nc -zv 172.16.4.250 993

# Test email sending
php public/test-email-simple.php
```

---

**Last Updated:** February 3, 2026  
**Status:** ✅ Both SMTP and IMAP configured and working
