mirror of
https://github.com/bluewave-labs/Checkmate.git
synced 2026-04-27 20:19:39 -05:00
Implement remaining email config
This commit is contained in:
@@ -50,6 +50,8 @@ const SettingsEmail = ({
|
||||
const emailConfig = {
|
||||
systemEmailHost: settingsData?.settings?.systemEmailHost,
|
||||
systemEmailPort: settingsData?.settings?.systemEmailPort,
|
||||
systemEmailSecure: settingsData?.settings?.systemEmailSecure,
|
||||
systemEmailPool: settingsData?.settings?.systemEmailPool,
|
||||
systemEmailUser: settingsData?.settings?.systemEmailUser,
|
||||
systemEmailAddress: settingsData?.settings?.systemEmailAddress,
|
||||
systemEmailPassword: password || settingsData?.settings?.systemEmailPassword,
|
||||
@@ -110,6 +112,27 @@ const SettingsEmail = ({
|
||||
onChange={handleChange}
|
||||
/>
|
||||
</Box>
|
||||
<Box
|
||||
sx={{
|
||||
display: "flex",
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
gap: theme.spacing(4),
|
||||
}}
|
||||
>
|
||||
<Typography>{t("settingsEmailSecure")}</Typography>
|
||||
<Switch
|
||||
name="systemEmailSecure"
|
||||
checked={settingsData?.settings?.systemEmailSecure ?? false}
|
||||
onChange={handleChange}
|
||||
/>
|
||||
<Typography>{t("settingsEmailPool")}</Typography>
|
||||
<Switch
|
||||
name="systemEmailPool"
|
||||
checked={settingsData?.settings?.systemEmailPool ?? false}
|
||||
onChange={handleChange}
|
||||
/>
|
||||
</Box>
|
||||
<Box>
|
||||
<Typography>{t("settingsEmailUser")}</Typography>
|
||||
<TextInput
|
||||
|
||||
@@ -67,7 +67,9 @@ const Settings = () => {
|
||||
if (
|
||||
name === "systemEmailIgnoreTLS" ||
|
||||
name === "systemEmailRequireTLS" ||
|
||||
name === "systemEmailRejectUnauthorized"
|
||||
name === "systemEmailRejectUnauthorized" ||
|
||||
name === "systemEmailSecure" ||
|
||||
name === "systemEmailPool"
|
||||
) {
|
||||
newValue = checked;
|
||||
}
|
||||
|
||||
@@ -1014,6 +1014,12 @@ class NetworkService {
|
||||
systemEmailPort: emailConfig.systemEmailPort,
|
||||
systemEmailAddress: emailConfig.systemEmailAddress,
|
||||
systemEmailPassword: emailConfig.systemEmailPassword,
|
||||
systemEmailSecure: emailConfig.systemEmailSecure,
|
||||
systemEmailPool: emailConfig.systemEmailPool,
|
||||
systemEmailIgnoreTLS: emailConfig.systemEmailIgnoreTLS,
|
||||
systemEmailRequireTLS: emailConfig.systemEmailRequireTLS,
|
||||
systemEmailRejectUnauthorized: emailConfig.systemEmailRejectUnauthorized,
|
||||
systemEmailTLSServername: emailConfig.systemEmailTLSServername,
|
||||
// Only include these if they are present
|
||||
...(emailConfig.systemEmailConnectionHost && {
|
||||
systemEmailConnectionHost: emailConfig.systemEmailConnectionHost,
|
||||
|
||||
@@ -290,6 +290,8 @@ const settingsValidation = joi.object({
|
||||
timezone: joi.string().allow("").optional(),
|
||||
systemEmailHost: joi.string().allow(""),
|
||||
systemEmailPort: joi.number().allow(null, ""),
|
||||
systemEmailSecure: joi.boolean().optional(),
|
||||
systemEmailPool: joi.boolean().optional(),
|
||||
systemEmailAddress: joi.string().allow(""),
|
||||
systemEmailPassword: joi.string().allow(""),
|
||||
systemEmailUser: joi.string().allow(""),
|
||||
|
||||
@@ -683,6 +683,8 @@
|
||||
"settingsEmailIgnoreTLS": "Ignore TLS",
|
||||
"settingsEmailRequireTLS": "Require TLS",
|
||||
"settingsEmailRejectUnauthorized": "Reject Unauthorized",
|
||||
"settingsEmailSecure": "Secure",
|
||||
"settingsEmailPool": "Pool",
|
||||
"state": "State",
|
||||
"statusBreadCrumbsStatusPages": "Status Pages",
|
||||
"statusBreadCrumbsDetails": "Details",
|
||||
|
||||
@@ -74,6 +74,12 @@ class SettingsController {
|
||||
systemEmailPassword,
|
||||
systemEmailUser,
|
||||
systemEmailConnectionHost,
|
||||
systemEmailSecure,
|
||||
systemEmailPool,
|
||||
systemEmailIgnoreTLS,
|
||||
systemEmailRequireTLS,
|
||||
systemEmailRejectUnauthorized,
|
||||
systemEmailTLSServername,
|
||||
} = req.body;
|
||||
|
||||
const subject = this.stringService.testEmailSubject;
|
||||
@@ -91,6 +97,12 @@ class SettingsController {
|
||||
systemEmailAddress,
|
||||
systemEmailPassword,
|
||||
systemEmailConnectionHost,
|
||||
systemEmailSecure,
|
||||
systemEmailPool,
|
||||
systemEmailIgnoreTLS,
|
||||
systemEmailRequireTLS,
|
||||
systemEmailRejectUnauthorized,
|
||||
systemEmailTLSServername,
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -101,6 +101,8 @@ class EmailService {
|
||||
const {
|
||||
systemEmailHost,
|
||||
systemEmailPort,
|
||||
systemEmailSecure,
|
||||
systemEmailPool,
|
||||
systemEmailUser,
|
||||
systemEmailAddress,
|
||||
systemEmailPassword,
|
||||
@@ -111,32 +113,23 @@ class EmailService {
|
||||
systemEmailRejectUnauthorized,
|
||||
} = config;
|
||||
|
||||
const baseEmailConfig = {
|
||||
const emailConfig = {
|
||||
host: systemEmailHost,
|
||||
port: Number(systemEmailPort),
|
||||
secure: true,
|
||||
secure: systemEmailSecure,
|
||||
auth: {
|
||||
user: systemEmailUser || systemEmailAddress,
|
||||
pass: systemEmailPassword,
|
||||
},
|
||||
connectionTimeout: 5000,
|
||||
pool: systemEmailPool,
|
||||
tls: { rejectUnauthorized: systemEmailRejectUnauthorized },
|
||||
ignoreTLS: systemEmailIgnoreTLS,
|
||||
requireTLS: systemEmailRequireTLS,
|
||||
servername: systemEmailTLSServername,
|
||||
name: systemEmailConnectionHost || "localhost",
|
||||
};
|
||||
|
||||
const isSmtps = Number(systemEmailPort) === 465;
|
||||
|
||||
const emailConfig = !isSmtps
|
||||
? {
|
||||
...baseEmailConfig,
|
||||
name: systemEmailConnectionHost || "localhost",
|
||||
secure: false,
|
||||
pool: true,
|
||||
tls: { rejectUnauthorized: systemEmailRejectUnauthorized },
|
||||
ignoreTLS: systemEmailIgnoreTLS,
|
||||
requireTLS: systemEmailRequireTLS,
|
||||
servername: systemEmailTLSServername,
|
||||
}
|
||||
: baseEmailConfig;
|
||||
|
||||
this.transporter = this.nodemailer.createTransport(emailConfig);
|
||||
|
||||
const buildHtml = async (template, context) => {
|
||||
|
||||
@@ -617,10 +617,16 @@ const sendTestEmailBodyValidation = joi.object({
|
||||
to: joi.string().required(),
|
||||
systemEmailHost: joi.string(),
|
||||
systemEmailPort: joi.number(),
|
||||
systemEmailSecure: joi.boolean(),
|
||||
systemEmailPool: joi.boolean(),
|
||||
systemEmailAddress: joi.string(),
|
||||
systemEmailPassword: joi.string(),
|
||||
systemEmailUser: joi.string(),
|
||||
systemEmailConnectionHost: joi.string(),
|
||||
systemEmailIgnoreTLS: joi.boolean(),
|
||||
systemEmailRequireTLS: joi.boolean(),
|
||||
systemEmailRejectUnauthorized: joi.boolean(),
|
||||
systemEmailTLSServername: joi.string(),
|
||||
});
|
||||
|
||||
export {
|
||||
|
||||
Reference in New Issue
Block a user