fix: Support Exchange servers without authentication
- Make email authentication optional in transporter config - Only add auth object if both username and password are provided - Update initialization to only require SMTP_HOST - Add logging to show whether auth is enabled - Update documentation with no-auth configuration examples - Fix "Unrecognized authentication type" error for open relays Exchange servers configured as internal relays often don't require authentication. This fix allows using them by leaving SMTP_USER and SMTP_PASS empty in the .env file. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
+24
-3
@@ -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`
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user