# Email Delivery Test Guide for playcoinkrazy.com

This guide provides step-by-step instructions for testing email delivery with Brevo SMTP and the new playcoinkrazy.com domain.

## Prerequisites

- Brevo account with SMTP credentials configured
- playcoinkrazy.com domain with DNS records set up
- Admin access to the PlayCoinKrazy application
- Test email address (use a personal email for testing)

## Test 1: Verify Brevo SMTP Connection

### Step 1: Check SMTP Credentials

1. Log in to Brevo dashboard
2. Go to Settings → SMTP & API
3. Verify SMTP credentials:
   - **SMTP Host:** smtp-relay.brevo.com
   - **SMTP Port:** 587 (TLS) or 465 (SSL)
   - **Username:** Your Brevo email
   - **Password:** Your SMTP password

### Step 2: Test Connection in Admin Panel

1. Log in to PlayCoinKrazy admin panel
2. Go to Settings → Email Configuration
3. Click "Test SMTP Connection"
4. Verify connection succeeds

### Step 3: Check Environment Variables

Verify these environment variables are set:
```
BREVO_SMTP_HOST=smtp-relay.brevo.com
BREVO_SMTP_PORT=587
BREVO_SMTP_USER=[your-brevo-email]
BREVO_SMTP_PASS=[your-smtp-password]
```

## Test 2: Send Test Campaign

### Step 1: Create Test Campaign

1. Go to Admin Panel → Email Campaigns
2. Click "Create Campaign"
3. Fill in campaign details:
   - **Name:** Test Campaign - playcoinkrazy.com
   - **Subject:** Testing email delivery from playcoinkrazy.com
   - **Template:** Welcome Email
   - **From:** noreply@playcoinkrazy.com
   - **Reply-To:** support@playcoinkrazy.com

### Step 2: Add Test Recipients

1. Add your test email address
2. Verify email format is correct
3. Check deliverability score (should be green)

### Step 3: Send Campaign

1. Click "Send Test Email" or "Send Campaign"
2. Wait 30 seconds for delivery
3. Check your test email inbox

### Step 4: Verify Email Received

Check the following in the received email:

**Email Headers:**
- From: noreply@playcoinkrazy.com
- Reply-To: support@playcoinkrazy.com
- Subject: Testing email delivery from playcoinkrazy.com

**Authentication:**
- SPF: PASS (check email headers)
- DKIM: PASS (check email headers)
- DMARC: PASS (check email headers)

**Content:**
- Email displays correctly
- All links work
- Images load properly
- Branding is correct

## Test 3: Monitor Delivery in Brevo

### Step 1: Check Campaign Stats

1. Log in to Brevo dashboard
2. Go to Campaigns → Sent Campaigns
3. Find your test campaign
4. Check delivery status:
   - ✅ Sent
   - ✅ Delivered
   - ⚠️ Bounced (if any)
   - ⚠️ Complained (if any)

### Step 2: Review Detailed Logs

1. Click on campaign name
2. Go to "Detailed Logs"
3. Verify your test email shows:
   - Status: Delivered
   - No bounce or complaint flags
   - Timestamp of delivery

### Step 3: Check Sender Reputation

1. Go to Settings → Senders & Domains
2. Select playcoinkrazy.com
3. Check sender reputation score
4. Verify authentication status:
   - SPF: ✅ Verified
   - DKIM: ✅ Verified
   - DMARC: ✅ Verified

## Test 4: Test Different Email Types

### Test Welcome Email

1. Create new user account
2. Verify welcome email is sent
3. Check email contains:
   - Correct recipient name
   - Welcome message
   - Account activation link
   - Company branding

### Test Password Reset Email

1. Go to login page
2. Click "Forgot Password"
3. Enter test email address
4. Verify password reset email received
5. Check email contains:
   - Password reset link
   - Expiration time
   - Company branding

### Test Promotional Email

1. Create promotional campaign
2. Send to test list
3. Verify email formatting
4. Check all links work
5. Verify unsubscribe link is present

### Test Transactional Email

1. Trigger a transactional event (e.g., withdrawal request)
2. Verify email is sent immediately
3. Check email contains:
   - Transaction details
   - Action buttons
   - Support contact info

## Test 5: Verify Authentication Records

### Check SPF Record

```bash
dig playcoinkrazy.com TXT
```

Expected output:
```
playcoinkrazy.com. 3600 IN TXT "v=spf1 include:brevo.net ~all"
```

### Check DKIM Record

```bash
dig default._domainkey.playcoinkrazy.com TXT
```

Expected output:
```
default._domainkey.playcoinkrazy.com. 3600 IN TXT "[DKIM public key]"
```

### Check DMARC Record

```bash
dig _dmarc.playcoinkrazy.com TXT
```

Expected output:
```
_dmarc.playcoinkrazy.com. 3600 IN TXT "v=DMARC1; p=quarantine; rua=mailto:admin@playcoinkrazy.com"
```

### Check MX Records

```bash
dig playcoinkrazy.com MX
```

Expected output:
```
playcoinkrazy.com. 3600 IN MX 10 mail.brevo.net.
playcoinkrazy.com. 3600 IN MX 20 mail2.brevo.net.
```

## Test 6: Monitor Deliverability Metrics

### Track Over 24 Hours

1. Send 5-10 test emails
2. Wait 24 hours
3. Check Brevo dashboard for:
   - **Delivery Rate:** Should be 100%
   - **Bounce Rate:** Should be < 2%
   - **Complaint Rate:** Should be < 0.1%
   - **Open Rate:** Monitor engagement
   - **Click Rate:** Monitor engagement

### Check Reputation Dashboard

1. Go to Admin Panel → Reputation Dashboard
2. Verify reputation score is "Good" or "Excellent"
3. Check all authentication records are verified
4. Verify no blacklist warnings

## Troubleshooting

### Email Not Received

**Check:**
1. Verify recipient email address is correct
2. Check spam/junk folder
3. Verify SMTP credentials in environment variables
4. Check Brevo campaign logs for bounce reason
5. Verify SPF/DKIM/DMARC records are correct

**Solution:**
1. Check email address in Brevo bounce list
2. Verify domain authentication is complete
3. Contact Brevo support if persistent

### Email Marked as Spam

**Check:**
1. Verify SPF/DKIM/DMARC records
2. Check email content for spam triggers
3. Verify sender reputation in Brevo
4. Check unsubscribe link is present

**Solution:**
1. Add unsubscribe link to all emails
2. Improve email content quality
3. Monitor complaint rates
4. Reduce sending volume if needed

### Authentication Failures

**Check:**
1. Verify SPF record includes Brevo
2. Verify DKIM key is correctly added
3. Verify DMARC record format
4. Check DNS propagation

**Solution:**
1. Re-add DNS records
2. Wait 24-48 hours for propagation
3. Use MXToolbox to verify records
4. Contact registrar if DNS not updating

### Slow Delivery

**Check:**
1. Verify SMTP connection is working
2. Check Brevo dashboard for queue
3. Monitor server logs
4. Check network connectivity

**Solution:**
1. Reduce batch size
2. Increase sending interval
3. Contact Brevo support
4. Check server resources

## Success Criteria

✅ **Email Delivery Test is Successful When:**

- All test emails are delivered within 5 minutes
- SPF, DKIM, and DMARC all show PASS in email headers
- Delivery rate is 100% in Brevo dashboard
- Bounce rate is < 2%
- Complaint rate is < 0.1%
- Reputation score is "Good" or "Excellent"
- No emails marked as spam
- All links in emails work correctly
- Unsubscribe link is functional
- Email formatting displays correctly

## Next Steps

1. **Monitor for 7 days** - Track delivery metrics
2. **Increase send volume gradually** - Follow warm-up schedule
3. **Monitor reputation** - Check daily in admin panel
4. **Adjust as needed** - Based on bounce/complaint rates
5. **Set up alerts** - Get notified of reputation changes

## Support

For issues with:
- **Email Delivery:** Check Brevo dashboard logs
- **SMTP Connection:** Verify credentials and firewall
- **DNS Records:** Contact domain registrar
- **Admin Panel:** Check application logs
