Fix email template loading and conditional TLS configuration
## Changes ### Server-side (emailService.js) - Fixed template path resolution: Changed default from `templates/` to `src/templates/` to correctly locate email templates in the project structure - Added EMAIL_TEMPLATE_PATH environment variable support for Docker deployments - Added input validation (validateEmailParams, validateFromAddress) to catch missing fields before attempting to send - Implemented conditional TLS configuration - TLS settings only applied when systemEmailSecure is enabled, allowing services like Resend to work properly - Added stronger content validation to prevent empty emails from being sent - Added transporter.verify() before sending to catch configuration issues early - Improved error logging with more context for debugging ### Client-side (SettingsEmail.jsx) - Refactored settings preview to use buildEmailConfigPreview() builder function - TLS fields now only shown in JSON preview when secure mode is enabled Fixes #3054
This commit is contained in:
1 parent
2f2ce34373
commit
8c27d60a85
2 files changed
+234
-49
No files matched your search
@@ -101,6 +101,47 @@ const SettingsEmail = ({
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build email configuration object for code preview
|
||||
* Constructs the config incrementally instead of using nested conditional spreads
|
||||
*/
|
||||
const buildEmailConfigPreview = () => {
|
||||
const config = {
|
||||
host: systemEmailHost,
|
||||
port: systemEmailPort,
|
||||
secure: systemEmailSecure,
|
||||
auth: {
|
||||
user: systemEmailUser || systemEmailAddress,
|
||||
pass: "<your_password>",
|
||||
},
|
||||
name: systemEmailConnectionHost || "localhost",
|
||||
pool: systemEmailPool,
|
||||
};
|
||||
|
||||
if (systemEmailSecure) {
|
||||
if (systemEmailIgnoreTLS) {
|
||||
config.ignoreTLS = systemEmailIgnoreTLS;
|
||||
}
|
||||
if (systemEmailRequireTLS) {
|
||||
config.requireTLS = systemEmailRequireTLS;
|
||||
}
|
||||
|
||||
const tlsSettings = {};
|
||||
if (systemEmailRejectUnauthorized !== undefined) {
|
||||
tlsSettings.rejectUnauthorized = systemEmailRejectUnauthorized;
|
||||
}
|
||||
if (systemEmailTLSServername && systemEmailTLSServername !== "") {
|
||||
tlsSettings.servername = systemEmailTLSServername;
|
||||
}
|
||||
|
||||
if (Object.keys(tlsSettings).length > 0) {
|
||||
config.tls = tlsSettings;
|
||||
}
|
||||
}
|
||||
|
||||
return config;
|
||||
};
|
||||
|
||||
return (
|
||||
<ConfigBox>
|
||||
<Box>
|
||||
@@ -271,29 +312,7 @@ const SettingsEmail = ({
|
||||
overflow: "auto",
|
||||
}}
|
||||
>
|
||||
<code>
|
||||
{JSON.stringify(
|
||||
{
|
||||
host: systemEmailHost,
|
||||
port: systemEmailPort,
|
||||
secure: systemEmailSecure,
|
||||
auth: {
|
||||
user: systemEmailUser || systemEmailAddress,
|
||||
pass: "<your_password>",
|
||||
},
|
||||
name: systemEmailConnectionHost || "localhost",
|
||||
pool: systemEmailPool,
|
||||
tls: {
|
||||
rejectUnauthorized: systemEmailRejectUnauthorized,
|
||||
ignoreTLS: systemEmailIgnoreTLS,
|
||||
requireTLS: systemEmailRequireTLS,
|
||||
servername: systemEmailTLSServername,
|
||||
},
|
||||
},
|
||||
null,
|
||||
2
|
||||
)}
|
||||
</code>
|
||||
<code>{JSON.stringify(buildEmailConfigPreview(), null, 2)}</code>
|
||||
</Box>
|
||||
</Box>
|
||||
|
||||
|
||||
Reference in new issue
Block a user