# Quick Email Setup Guide

## Problem
Your verification code emails are not being sent because the mail driver is set to 'log' instead of actually sending emails.

## Quick Fix - Gmail SMTP

Add these settings to your `.env` file:

```env
# Mail Configuration
MAIL_MAILER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=your-email@gmail.com
MAIL_PASSWORD=your-app-password
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=your-email@gmail.com
MAIL_FROM_NAME="Firmly KYC System"
```

### Gmail Setup Steps:
1. **Enable 2-factor authentication** on your Gmail account
2. **Generate an App Password**:
   - Go to Google Account settings
   - Security → 2-Step Verification → App passwords
   - Generate a new app password for "Mail"
3. **Use the App Password** (not your regular Gmail password) in `MAIL_PASSWORD`
4. **Replace** `your-email@gmail.com` with your actual Gmail address

## Alternative: Use Mailtrap (For Development)

If you prefer not to use Gmail, you can use Mailtrap for testing:

```env
MAIL_MAILER=smtp
MAIL_HOST=sandbox.smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=your-mailtrap-username
MAIL_PASSWORD=your-mailtrap-password
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=test@firmly.pt
MAIL_FROM_NAME="Firmly KYC System"
```

## Test Email Configuration

After updating your `.env` file:

1. **Clear config cache**:
   ```bash
   php artisan config:clear
   ```

2. **Test email sending**:
   Visit: `http://localhost:8000/test-email` (while logged in)

3. **Test KYC verification**:
   - Go to a KYC form
   - Enter an authorized email address
   - Click "Send Verification Code"
   - Check if the email is received

## Troubleshooting

### If emails still don't work:

1. **Check Laravel logs**:
   ```bash
   tail -f storage/logs/laravel.log
   ```

2. **Verify .env settings**:
   ```bash
   php artisan tinker
   config('mail.default')
   config('mail.mailers.smtp')
   ```

3. **Test with a simple email**:
   ```bash
   php artisan tinker
   Mail::raw('Test email', function($m) { $m->to('test@example.com')->subject('Test'); });
   ```

## Security Note

- Never commit your `.env` file to version control
- Use App Passwords for Gmail, not your regular password
- For production, consider using a dedicated email service like SendGrid, Mailgun, or Amazon SES
