# Email Configuration Fix Guide

## Problem
Emails are not being sent because the mail configuration is set to 'log' mode instead of actual SMTP.

## Solution Steps:

### 1. Update your .env file with proper SMTP settings:

```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="${APP_NAME}"
```

### 2. For Gmail Users:
- Enable 2-factor authentication on your Gmail account
- Generate an App Password: https://myaccount.google.com/apppasswords
- Use the App Password (16-character code) as MAIL_PASSWORD
- NOT your regular Gmail password

### 3. Alternative SMTP Providers:

**For Outlook/Hotmail:**
```env
MAIL_HOST=smtp-mail.outlook.com
MAIL_PORT=587
```

**For SendGrid:**
```env
MAIL_HOST=smtp.sendgrid.net
MAIL_PORT=587
MAIL_USERNAME=apikey
MAIL_PASSWORD=YOUR_SENDGRID_API_KEY
```

**For Mailgun:**
```env
MAIL_HOST=smtp.mailgun.org
MAIL_PORT=587
MAIL_USERNAME=postmaster@yourdomain.com
MAIL_PASSWORD=YOUR_MAILGUN_PASSWORD
```

### 4. After updating .env:
1. Clear configuration cache: `php artisan config:clear`
2. Clear application cache: `php artisan cache:clear`
3. Test email sending

### 5. Test Email Sending:
Run this command to test:
```bash
php artisan tinker
```
Then run:
```php
Mail::raw('Test email', function($message) {
    $message->to('your-test-email@example.com')->subject('Test Email');
});
```

### 6. Common Issues & Fixes:

**Issue: "Connection could not be established"**
- Check MAIL_HOST and PORT are correct
- Ensure firewall allows SMTP connections
- Verify username/password are correct

**Issue: "Authentication failed"**
- Use App Password for Gmail (not regular password)
- Check 2FA is enabled for Gmail
- Verify username includes full email address

**Issue: "SSL/TLS error"**
- Set MAIL_ENCRYPTION=tls for port 587
- Set MAIL_ENCRYPTION=ssl for port 465

### 7. Debug Mode:
Add this to your .env to see detailed error logs:
```env
LOG_LEVEL=debug
```

Then check: `storage/logs/laravel.log` for detailed error messages.
