mirror of
https://github.com/DeNNiiInc/Advanced-Smtp-Tester.git
synced 2026-04-18 09:45:59 +00:00
Fix SMTP encryption logic for STARTTLS and Unencrypted modes
This commit is contained in:
18
server.js
18
server.js
@@ -27,22 +27,28 @@ app.post('/api/test-smtp', async (req, res) => {
|
|||||||
}) for ${user}`
|
}) for ${user}`
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Parse secure setting
|
||||||
|
const isSecure = secure === true || secure === "true";
|
||||||
|
const isNone = secure === "none";
|
||||||
|
|
||||||
// Create Transporter
|
// Create Transporter
|
||||||
const transporterConfig = {
|
const transporterConfig = {
|
||||||
host: host,
|
host: host,
|
||||||
port: parseInt(port),
|
port: parseInt(port),
|
||||||
secure: secure === true || secure === "true", // true for 465, false for other ports
|
secure: isSecure, // true for 465, false for other ports
|
||||||
auth: {
|
auth: {
|
||||||
user: user,
|
user: user,
|
||||||
pass: pass,
|
pass: pass,
|
||||||
},
|
},
|
||||||
|
tls: {
|
||||||
|
rejectUnauthorized: false, // Default to allowing self-signed
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Only add TLS settings if secure is not explicitly "none"
|
// Handle Unencrypted (Force Cleartext)
|
||||||
if (secure !== "none") {
|
if (isNone) {
|
||||||
transporterConfig.tls = {
|
transporterConfig.ignoreTLS = true;
|
||||||
rejectUnauthorized: false, // Allow self-signed certs for testing flexibility
|
delete transporterConfig.tls; // Remove TLS config for cleartext
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user