feat: add OpenSSL setup guide and enhance email logging functionality

This commit is contained in:
2025-11-24 14:55:57 +01:00
parent 3a2926675a
commit 22b3fe9d0b
5 changed files with 462 additions and 93 deletions

View File

@@ -95,13 +95,61 @@
- Set environment variables through hosting control panel
- Test mail() function first before adding SMTP
## Email Logging
The application now includes comprehensive email logging:
- **Log Location**: `php/mail.log`
- **Log Format**: `[YYYY-MM-DD HH:MM:SS] [LEVEL] Message`
- **Configuration**:
- Set `LOG_ENABLED = true` in `config.php` to enable logging
- Logs are also written to PHP error_log with `[MAIL]` prefix
### What Gets Logged
- Email send attempts with from/to/subject
- Email content length
- SMTP connection details (host, port, encryption)
- PHPMailer initialization and configuration steps
- Success/failure status for each send attempt
- Detailed error messages for failed sends
- When mail is disabled (includes full XML content)
### Viewing Logs
```bash
# View recent log entries
tail -f php/mail.log
# View last 50 lines
tail -n 50 php/mail.log
# Search for errors
grep ERROR php/mail.log
# Search for successful sends
grep SUCCESS php/mail.log
```
### Log File Management
The log file is automatically created when needed. To rotate logs:
```bash
# Manual rotation
mv php/mail.log php/mail.log.$(date +%Y%m%d)
touch php/mail.log
chmod 666 php/mail.log
```
## Troubleshooting
### Emails not sending
1. Check `MAIL_ENABLED` is set to `true`
2. Verify SMTP credentials are correct
3. Check server error logs: `tail -f /var/log/apache2/error.log`
4. Test with `MAIL_ENABLED=false` to see XML output in logs
2. **Check `php/mail.log`** for detailed error messages
3. Verify SMTP credentials are correct
4. Check server error logs: `tail -f /var/log/apache2/error.log`
5. Test with `MAIL_ENABLED=false` to see XML output in logs
### Form validation errors
- Ensure all required fields have values