Add option to ignore SSL/TLS certificate errors for email (Issue #53)

This feature allows users with non-standard SMTP setups (shared hosting,
self-signed certificates) to bypass certificate validation when needed.

Changes:
- Add database migration for tls_reject_unauthorized column
- Update emailProcessor.js to pass TLS option to nodemailer
- Update adminEmail.js routes to handle the new field
- Add checkbox UI with security warning in EmailConfigPage
- Add English and German translations
This commit is contained in:
Claude
2025-11-25 20:23:39 +00:00
parent ee1aa7e5cb
commit e85d1bf72a
7 changed files with 97 additions and 12 deletions
+9 -2
View File
@@ -18,7 +18,8 @@ router.get('/config', adminAuth, async (req, res) => {
smtp_user: '',
smtp_pass: '', // Don't send actual password
from_email: '',
from_name: ''
from_name: '',
tls_reject_unauthorized: true
});
}
@@ -53,7 +54,8 @@ router.post('/config', [
smtp_user,
smtp_pass,
from_email,
from_name
from_name,
tls_reject_unauthorized
} = req.body;
// Check if config exists
@@ -66,6 +68,7 @@ router.post('/config', [
smtp_user: smtp_user || '',
from_email,
from_name: from_name || 'Photo Sharing',
tls_reject_unauthorized: tls_reject_unauthorized !== false, // Default to true
updated_at: new Date()
};
@@ -137,6 +140,10 @@ router.post('/test', adminAuth, async (req, res) => {
user: config.smtp_user,
pass: config.smtp_pass
} : undefined,
tls: {
// Allow ignoring SSL certificate errors when tls_reject_unauthorized is false
rejectUnauthorized: config.tls_reject_unauthorized !== false
},
logger: process.env.NODE_ENV === 'development',
debug: process.env.NODE_ENV === 'development'
};
+6 -2
View File
@@ -9,7 +9,7 @@ let lastConfigHash = null;
// Generate hash from config for change detection
function generateConfigHash(config) {
const crypto = require('crypto');
const configString = `${config.smtp_host}:${config.smtp_port}:${config.smtp_user}:${config.smtp_pass}:${config.smtp_secure}`;
const configString = `${config.smtp_host}:${config.smtp_port}:${config.smtp_user}:${config.smtp_pass}:${config.smtp_secure}:${config.tls_reject_unauthorized}`;
return crypto.createHash('md5').update(configString).digest('hex');
}
@@ -40,7 +40,11 @@ async function initializeTransporter(forceReinit = false) {
auth: config.smtp_user ? {
user: config.smtp_user,
pass: config.smtp_pass
} : undefined
} : undefined,
tls: {
// Allow ignoring SSL certificate errors when tls_reject_unauthorized is false
rejectUnauthorized: config.tls_reject_unauthorized !== false
}
});
// Verify configuration