Skip to content

Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.

🔒️ Secure SMTP defaults (#1932)

Luke Vellaa35af3947123
diff --git a/apps/docs/self-hosting/configuration.mdx b/apps/docs/self-hosting/configuration.mdx
index 67e19d31f..5d751f5a4 100644
--- a/apps/docs/self-hosting/configuration.mdx
+++ b/apps/docs/self-hosting/configuration.mdx
@@ -43,12 +43,12 @@ description: Using environment variable to configure a self-hosted instance of R
<ParamField path="SMTP_HOST">The host address of your SMTP server</ParamField>
-<ParamField path="SMTP_PORT" default="25 or 465">
- The port of your SMTP server
+<ParamField path="SMTP_PORT">
+ The port of your SMTP server. Common values: 587 (STARTTLS), 465 (SSL), 25 (plain).
</ParamField>
<ParamField path="SMTP_SECURE" default="false">
- Set to "true" if SSL is enabled for your SMTP connection
+ Set to "true" if SSL is enabled for your SMTP connection (typically for port 465)
</ParamField>
<ParamField path="SMTP_USER" default="">
@@ -59,8 +59,13 @@ description: Using environment variable to configure a self-hosted instance of R
The password (if auth is enabled on your SMTP server)
</ParamField>
-<ParamField path="SMTP_TLS_ENABLED" default={"false"}>
- Enable TLS for your SMTP connection
+<ParamField path="SMTP_REJECT_UNAUTHORIZED" default="true">
+ Validate TLS certificates. Set to `false` to ignore certificate errors (useful for self-signed certificates, not recommended for production)
+</ParamField>
+
+<ParamField path="SMTP_TLS_ENABLED">
+ <Warning>Deprecated: Use `SMTP_REJECT_UNAUTHORIZED=false` to disable certificate validation</Warning>
+ Legacy option that is no longer used
</ParamField>
## Auth
diff --git a/apps/web/src/env.ts b/apps/web/src/env.ts
index 862bd536d..69df1eefe 100644
--- a/apps/web/src/env.ts
+++ b/apps/web/src/env.ts
@@ -35,8 +35,11 @@ export const env = createEnv({
SMTP_HOST: z.string().optional(),
SMTP_USER: z.string().optional(),
SMTP_PWD: z.string().optional(),
- SMTP_SECURE: z.string().optional(),
+ SMTP_SECURE: z.enum(["true", "false"]).optional(),
SMTP_PORT: z.string().optional(),
+ SMTP_REJECT_UNAUTHORIZED: z.enum(["true", "false"]).optional(),
+ /** @deprecated Use SMTP_REJECT_UNAUTHORIZED instead */
+ SMTP_TLS_ENABLED: z.enum(["true", "false"]).optional(),
/**
* AWS SES Configuration
*/
@@ -117,6 +120,8 @@ export const env = createEnv({
SMTP_PWD: process.env.SMTP_PWD,
SMTP_SECURE: process.env.SMTP_SECURE,
SMTP_PORT: process.env.SMTP_PORT,
+ SMTP_REJECT_UNAUTHORIZED: process.env.SMTP_REJECT_UNAUTHORIZED,
+ SMTP_TLS_ENABLED: process.env.SMTP_TLS_ENABLED,
ALLOWED_EMAILS: process.env.ALLOWED_EMAILS,
EMAIL_LOGIN_ENABLED: process.env.EMAIL_LOGIN_ENABLED,
REGISTRATION_ENABLED: process.env.REGISTRATION_ENABLED,
diff --git a/packages/emails/src/send-email.tsx b/packages/emails/src/send-email.tsx
index b618efe90..c3ac2e527 100644
--- a/packages/emails/src/send-email.tsx
+++ b/packages/emails/src/send-email.tsx
@@ -176,12 +176,36 @@ export class EmailClient {
}
case "smtp": {
const hasAuth = process.env.SMTP_USER || process.env.SMTP_PWD;
+ const port = process.env.SMTP_PORT
+ ? Number.parseInt(process.env.SMTP_PORT)
+ : undefined;
+
+ const secure = process.env.SMTP_SECURE === "true";
+
+ // Log deprecation warning for legacy variable
+ if (process.env.SMTP_TLS_ENABLED === "true") {
+ console.warn(
+ "⚠️ SMTP_TLS_ENABLED is deprecated and no longer affects certificate validation. Use SMTP_REJECT_UNAUTHORIZED instead.",
+ );
+ }
+
+ const rejectUnauthorized =
+ process.env.SMTP_REJECT_UNAUTHORIZED !== "false";
+
+ // Warn about security change if no explicit setting
+ if (
+ process.env.SMTP_REJECT_UNAUTHORIZED === undefined &&
+ process.env.SMTP_TLS_ENABLED === undefined
+ ) {
+ console.warn(
+ "⚠️ Certificate validation is now enabled by default for SMTP connections. Set SMTP_REJECT_UNAUTHORIZED=true to silence this warning, or SMTP_REJECT_UNAUTHORIZED=false if using self-signed certificates.",
+ );
+ }
+
this.cachedTransport = createTransport({
host: process.env.SMTP_HOST,
- port: process.env.SMTP_PORT
- ? Number.parseInt(process.env.SMTP_PORT)
- : undefined,
- secure: process.env.SMTP_SECURE === "true",
+ port,
+ secure,
auth: hasAuth
? {
user: process.env.SMTP_USER,
@@ -189,7 +213,7 @@ export class EmailClient {
}
: undefined,
tls: {
- rejectUnauthorized: process.env.SMTP_TLS_ENABLED === "true",
+ rejectUnauthorized,
},
});
break;