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 <[email protected]>
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:
|
Configure these variables in your `.env` file:
|
||||||
|
|
||||||
|
### With Authentication (Most servers)
|
||||||
```bash
|
```bash
|
||||||
# SMTP Server Configuration
|
# SMTP Server Configuration
|
||||||
SMTP_HOST=your-exchange-server.com
|
SMTP_HOST=your-exchange-server.com
|
||||||
@@ -24,6 +25,24 @@ [email protected]
|
|||||||
REPORT_SCHEDULE=0 0 * * 1 # Every Monday at midnight
|
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=[email protected]
|
||||||
|
REPORT_RECIPIENT=[email protected]
|
||||||
|
|
||||||
|
# Report Schedule (cron format)
|
||||||
|
REPORT_SCHEDULE=0 0 * * 1 # Every Monday at midnight
|
||||||
|
```
|
||||||
|
|
||||||
## Port and Security Settings
|
## Port and Security Settings
|
||||||
|
|
||||||
### Port 25 (No TLS/SSL)
|
### Port 25 (No TLS/SSL)
|
||||||
@@ -70,11 +89,13 @@ SMTP_SECURE=true
|
|||||||
|
|
||||||
### Authentication Failed
|
### Authentication Failed
|
||||||
|
|
||||||
**Error**: `Invalid login`
|
**Error**: `Invalid login` or `Unrecognized authentication type`
|
||||||
|
|
||||||
**Solution**:
|
**Solution**:
|
||||||
1. Verify SMTP_USER and SMTP_PASS are correct
|
1. If your Exchange server doesn't require authentication (internal relay):
|
||||||
2. For Exchange, use either:
|
- 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`
|
- Username only: `username`
|
||||||
- Domain\Username: `DOMAIN\\username`
|
- Domain\Username: `DOMAIN\\username`
|
||||||
- Email format: `[email protected]`
|
- Email format: `[email protected]`
|
||||||
|
|||||||
@@ -10,23 +10,19 @@ class ReportService {
|
|||||||
this.transporter = null;
|
this.transporter = null;
|
||||||
this.scheduledTask = null;
|
this.scheduledTask = null;
|
||||||
|
|
||||||
if (config.email.host && config.email.auth.user) {
|
if (config.email.host) {
|
||||||
this.initializeMailer();
|
this.initializeMailer();
|
||||||
this.setupSchedule();
|
this.setupSchedule();
|
||||||
} else {
|
} else {
|
||||||
logger.warn('Email configuration missing. Report scheduling disabled.');
|
logger.warn('Email host not configured. Report scheduling disabled.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
initializeMailer() {
|
initializeMailer() {
|
||||||
this.transporter = nodemailer.createTransport({
|
const transportConfig = {
|
||||||
host: config.email.host,
|
host: config.email.host,
|
||||||
port: config.email.port,
|
port: config.email.port,
|
||||||
secure: config.email.secure,
|
secure: config.email.secure,
|
||||||
auth: {
|
|
||||||
user: config.email.auth.user,
|
|
||||||
pass: config.email.auth.pass,
|
|
||||||
},
|
|
||||||
// For Exchange Server on port 25 without TLS
|
// For Exchange Server on port 25 without TLS
|
||||||
tls: {
|
tls: {
|
||||||
rejectUnauthorized: false, // Accept self-signed certificates
|
rejectUnauthorized: false, // Accept self-signed certificates
|
||||||
@@ -36,7 +32,20 @@ class ReportService {
|
|||||||
// Disable STARTTLS for port 25 if not using secure
|
// Disable STARTTLS for port 25 if not using secure
|
||||||
requireTLS: config.email.secure,
|
requireTLS: config.email.secure,
|
||||||
ignoreTLS: config.email.port === 25 && !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
|
// Verify connection
|
||||||
this.transporter.verify((error) => {
|
this.transporter.verify((error) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user