From 3d44265f6dc0a3041cbdf560dc2c85d5f89fc050 Mon Sep 17 00:00:00 2001 From: paul Date: Thu, 24 Jul 2025 08:47:44 +0200 Subject: [PATCH] fix: Resolve Exchange email server self-signed certificate error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add TLS configuration to accept self-signed certificates - Disable TLS/STARTTLS for port 25 when SMTP_SECURE=false - Add ignoreTLS option for Exchange servers on port 25 - Update .env.example with Exchange-specific configuration - Create comprehensive EMAIL_CONFIGURATION.md guide - Support both Exchange internal servers and modern SMTP servers This fixes the "self-signed certificate" error when connecting to Microsoft Exchange servers on port 25 without TLS. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .env.example | 15 +- EMAIL_CONFIGURATION.md | 194 +++++++++++++++++++++++++ backend/src/services/report.service.js | 9 ++ 3 files changed, 214 insertions(+), 4 deletions(-) create mode 100644 EMAIL_CONFIGURATION.md diff --git a/.env.example b/.env.example index 5bb57b1..bdee521 100644 --- a/.env.example +++ b/.env.example @@ -23,11 +23,18 @@ MINIO_ACCESS_KEY=minioadmin MINIO_SECRET_KEY=minioadmin # Email Configuration (for reports) -SMTP_HOST=smtp.gmail.com -SMTP_PORT=587 +# For Microsoft Exchange on port 25 without TLS: +SMTP_HOST=exchange.yourcompany.com +SMTP_PORT=25 SMTP_SECURE=false -SMTP_USER=your-email@gmail.com -SMTP_PASS=your-app-password +SMTP_USER=username +SMTP_PASS=password +# For Gmail/Office365 with STARTTLS: +# SMTP_HOST=smtp.gmail.com +# SMTP_PORT=587 +# SMTP_SECURE=false +# SMTP_USER=your-email@gmail.com +# SMTP_PASS=your-app-password REPORT_RECIPIENT=info@example.com REPORT_SENDER=kopiabackup@example.com diff --git a/EMAIL_CONFIGURATION.md b/EMAIL_CONFIGURATION.md new file mode 100644 index 0000000..adfa68f --- /dev/null +++ b/EMAIL_CONFIGURATION.md @@ -0,0 +1,194 @@ +# Email Configuration Guide for MinIO WebUI + +## Overview + +MinIO WebUI supports email notifications for storage reports. This guide explains how to configure email settings, especially for Microsoft Exchange servers. + +## Environment Variables + +Configure these variables in your `.env` file: + +```bash +# SMTP Server Configuration +SMTP_HOST=your-exchange-server.com +SMTP_PORT=25 +SMTP_SECURE=false +SMTP_USER=your-username +SMTP_PASS=your-password + +# Email Settings +REPORT_SENDER=minio-reports@yourdomain.com +REPORT_RECIPIENT=admin@yourdomain.com + +# Report Schedule (cron format) +REPORT_SCHEDULE=0 0 * * 1 # Every Monday at midnight +``` + +## Port and Security Settings + +### Port 25 (No TLS/SSL) +Most common for internal Exchange servers: +```bash +SMTP_PORT=25 +SMTP_SECURE=false +``` + +### Port 587 (STARTTLS) +For servers that support encryption: +```bash +SMTP_PORT=587 +SMTP_SECURE=false # STARTTLS will upgrade the connection +``` + +### Port 465 (SSL/TLS) +For servers requiring SSL from the start: +```bash +SMTP_PORT=465 +SMTP_SECURE=true +``` + +## Common Issues and Solutions + +### Self-Signed Certificate Error + +**Error**: `self-signed certificate` + +**Solution**: The application is configured to accept self-signed certificates. If you still see this error: + +1. Ensure `SMTP_SECURE=false` for port 25 +2. Restart the backend service +3. Check that your Exchange server allows SMTP connections on port 25 + +### Connection Refused + +**Error**: `connect ECONNREFUSED` + +**Solution**: +1. Verify the SMTP_HOST is correct +2. Check if port 25 is open on the Exchange server +3. Ensure no firewall is blocking the connection + +### Authentication Failed + +**Error**: `Invalid login` + +**Solution**: +1. Verify SMTP_USER and SMTP_PASS are correct +2. For Exchange, use either: + - Username only: `username` + - Domain\Username: `DOMAIN\\username` + - Email format: `username@domain.com` + +## Exchange Server Specific Settings + +For Microsoft Exchange servers, the configuration automatically: +- Accepts self-signed certificates when `SMTP_SECURE=false` +- Disables TLS for port 25 when `SMTP_SECURE=false` +- Handles STARTTLS negotiation for port 587 + +## Testing Email Configuration + +1. Set up your environment variables +2. Restart the backend: + ```bash + docker-compose restart backend + ``` +3. Check the logs: + ```bash + docker logs minio-webui-backend -f + ``` +4. Look for either: + - ✅ `Email transporter ready` + - ❌ `Email transporter verification failed` + +## Manual Test + +To manually trigger a test email: +1. Log into the MinIO WebUI +2. Navigate to Reports +3. Click "E-Mail senden" (Send Email) + +## Report Schedule Format + +The `REPORT_SCHEDULE` uses cron format: + +``` +┌────────────── second (optional) +│ ┌──────────── minute +│ │ ┌────────── hour +│ │ │ ┌──────── day of month +│ │ │ │ ┌────── month +│ │ │ │ │ ┌──── day of week +│ │ │ │ │ │ +* * * * * * +``` + +Examples: +- `0 0 * * 1` - Every Monday at midnight +- `0 8 * * *` - Every day at 8 AM +- `0 0 1 * *` - First day of every month at midnight +- `0 */6 * * *` - Every 6 hours + +## Troubleshooting + +### Enable Debug Logging + +Add to your `.env`: +```bash +LOG_LEVEL=debug +``` + +### Check Email Service Status + +```bash +# View recent logs +docker logs minio-webui-backend --tail 50 + +# Watch logs in real-time +docker logs minio-webui-backend -f +``` + +### Common Exchange Configurations + +**Internal Exchange (No Auth)**: +```bash +SMTP_HOST=exchange.internal.company.com +SMTP_PORT=25 +SMTP_SECURE=false +SMTP_USER= +SMTP_PASS= +``` + +**Exchange with Auth**: +```bash +SMTP_HOST=mail.company.com +SMTP_PORT=25 +SMTP_SECURE=false +SMTP_USER=DOMAIN\\username +SMTP_PASS=yourpassword +``` + +**Office 365**: +```bash +SMTP_HOST=smtp.office365.com +SMTP_PORT=587 +SMTP_SECURE=false +SMTP_USER=user@company.com +SMTP_PASS=yourpassword +``` + +## Security Considerations + +1. Store credentials securely in `.env` file +2. Never commit `.env` to version control +3. Use application-specific passwords when available +4. Consider using OAuth2 for modern email services +5. Restrict SMTP relay access on Exchange server + +## Need Help? + +If email configuration continues to fail: +1. Verify with your IT team that SMTP is enabled on the Exchange server +2. Check if any additional authentication (like NTLM) is required +3. Test connectivity: `telnet your-exchange-server 25` +4. Review Exchange server logs for connection attempts \ No newline at end of file diff --git a/backend/src/services/report.service.js b/backend/src/services/report.service.js index 78703ab..00f4b7c 100644 --- a/backend/src/services/report.service.js +++ b/backend/src/services/report.service.js @@ -27,6 +27,15 @@ class ReportService { user: config.email.auth.user, pass: config.email.auth.pass, }, + // For Exchange Server on port 25 without TLS + tls: { + rejectUnauthorized: false, // Accept self-signed certificates + // If you want to disable TLS completely when secure is false: + ...(config.email.port === 25 && !config.email.secure ? { enabled: false } : {}) + }, + // Disable STARTTLS for port 25 if not using secure + requireTLS: config.email.secure, + ignoreTLS: config.email.port === 25 && !config.email.secure, }); // Verify connection