diff --git a/EMAIL_CONFIGURATION.md b/EMAIL_CONFIGURATION.md index adfa68f..759889a 100644 --- a/EMAIL_CONFIGURATION.md +++ b/EMAIL_CONFIGURATION.md @@ -8,6 +8,7 @@ MinIO WebUI supports email notifications for storage reports. This guide explain Configure these variables in your `.env` file: +### With Authentication (Most servers) ```bash # SMTP Server Configuration SMTP_HOST=your-exchange-server.com @@ -24,6 +25,24 @@ REPORT_RECIPIENT=admin@yourdomain.com REPORT_SCHEDULE=0 0 * * 1 # Every Monday at midnight ``` +### Without Authentication (Open Relay/Internal Exchange) +```bash +# SMTP Server Configuration +SMTP_HOST=exchange.internal.company.com +SMTP_PORT=25 +SMTP_SECURE=false +# Leave SMTP_USER and SMTP_PASS empty or don't include them +SMTP_USER= +SMTP_PASS= + +# 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) @@ -70,11 +89,13 @@ SMTP_SECURE=true ### Authentication Failed -**Error**: `Invalid login` +**Error**: `Invalid login` or `Unrecognized authentication type` **Solution**: -1. Verify SMTP_USER and SMTP_PASS are correct -2. For Exchange, use either: +1. If your Exchange server doesn't require authentication (internal relay): + - Leave `SMTP_USER` and `SMTP_PASS` empty in your .env file + - Or remove these variables entirely +2. If authentication is required, verify credentials: - Username only: `username` - Domain\Username: `DOMAIN\\username` - Email format: `username@domain.com` diff --git a/backend/src/services/report.service.js b/backend/src/services/report.service.js index 00f4b7c..cf694e7 100644 --- a/backend/src/services/report.service.js +++ b/backend/src/services/report.service.js @@ -10,23 +10,19 @@ class ReportService { this.transporter = null; this.scheduledTask = null; - if (config.email.host && config.email.auth.user) { + if (config.email.host) { this.initializeMailer(); this.setupSchedule(); } else { - logger.warn('Email configuration missing. Report scheduling disabled.'); + logger.warn('Email host not configured. Report scheduling disabled.'); } } initializeMailer() { - this.transporter = nodemailer.createTransport({ + const transportConfig = { host: config.email.host, port: config.email.port, secure: config.email.secure, - auth: { - 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 @@ -36,7 +32,20 @@ class ReportService { // Disable STARTTLS for port 25 if not using secure requireTLS: config.email.secure, ignoreTLS: config.email.port === 25 && !config.email.secure, - }); + }; + + // Only add auth if username and password are provided + if (config.email.auth.user && config.email.auth.pass) { + transportConfig.auth = { + user: config.email.auth.user, + pass: config.email.auth.pass, + }; + logger.info('Email configured with authentication'); + } else { + logger.info('Email configured without authentication (open relay)'); + } + + this.transporter = nodemailer.createTransport(transportConfig); // Verify connection this.transporter.verify((error) => {