feat: possibility to set mail from name (#4864)

Co-authored-by: Piyush Gupta <piyushguptaa2z123@gmail.com>
Co-authored-by: Johannes <johannes@formbricks.com>
This commit is contained in:
IllimarR
2025-03-13 14:50:15 +02:00
committed by GitHub
parent 0164eca206
commit 2d028d18e5
10 changed files with 21 additions and 1 deletions

View File

@@ -39,6 +39,7 @@ DATABASE_URL='postgresql://postgres:postgres@localhost:5432/formbricks?schema=pu
# See optional configurations below if you want to disable these features.
MAIL_FROM=noreply@example.com
MAIL_FROM_NAME=Formbricks
SMTP_HOST=localhost
SMTP_PORT=1025
# Enable SMTP_SECURE_ENABLED for TLS (port 465)
@@ -207,3 +208,4 @@ UNKEY_ROOT_KEY=
# Enable Prometheus metrics
# PROMETHEUS_ENABLED=
# PROMETHEUS_EXPORTER_PORT=

View File

@@ -6,6 +6,7 @@ import type SMTPTransport from "nodemailer/lib/smtp-transport";
import {
DEBUG,
MAIL_FROM,
MAIL_FROM_NAME,
SMTP_AUTHENTICATED,
SMTP_HOST,
SMTP_PASSWORD,
@@ -69,7 +70,7 @@ export const sendEmail = async (emailData: SendEmailDataProps): Promise<boolean>
} as SMTPTransport.Options);
const emailDefaults = {
from: `Formbricks <${MAIL_FROM ?? "noreply@formbricks.com"}>`,
from: `${MAIL_FROM_NAME ?? "Formbricks"} <${MAIL_FROM ?? "noreply@formbricks.com"}>`,
};
await transporter.sendMail({ ...emailDefaults, ...emailData });

View File

@@ -36,6 +36,7 @@ x-environment: &environment
# Email Configuration
# MAIL_FROM:
# MAIL_FROM_NAME:
# SMTP_HOST:
# SMTP_PORT:
# SMTP_USER:

View File

@@ -224,6 +224,9 @@ EOT
echo -n "Enter your SMTP configured Email ID: "
read mail_from
echo -n "Enter your SMTP configured Email Name: "
read mail_from_name
echo -n "Enter your SMTP Host URL: "
read smtp_host
@@ -244,6 +247,7 @@ EOT
else
mail_from=""
mail_from_name=""
smtp_host=""
smtp_port=""
smtp_user=""
@@ -270,6 +274,7 @@ EOT
if [[ -n $mail_from ]]; then
sed -i "s|# MAIL_FROM:|MAIL_FROM: \"$mail_from\"|" docker-compose.yml
sed -i "s|# MAIL_FROM_NAME:|MAIL_FROM_NAME: \"$mail_from_name\"|" docker-compose.yml
sed -i "s|# SMTP_HOST:|SMTP_HOST: \"$smtp_host\"|" docker-compose.yml
sed -i "s|# SMTP_PORT:|SMTP_PORT: \"$smtp_port\"|" docker-compose.yml
sed -i "s|# SMTP_SECURE_ENABLED:|SMTP_SECURE_ENABLED: $smtp_secure_enabled|" docker-compose.yml

View File

@@ -1039,6 +1039,7 @@ x-environment: &environment
# Email Configuration
MAIL_FROM:
MAIL_FROM_NAME:
SMTP_HOST:
SMTP_PORT:
SMTP_SECURE_ENABLED:

View File

@@ -33,6 +33,7 @@ These variables are present inside your machines docker-compose file. Restart
| RATE_LIMITING_DISABLED | Disables rate limiting if set to 1. | optional | |
| INVITE_DISABLED | Disables the ability for invited users to create an account if set to 1. | optional | |
| MAIL_FROM | Email address to send emails from. | optional (required if email services are to be enabled) | |
| MAIL_FROM_NAME | Email name/title to send emails from. | optional (required if email services are to be enabled) | |
| SMTP_HOST | Host URL of your SMTP server. | optional (required if email services are to be enabled) | |
| SMTP_PORT | Host Port of your SMTP server. | optional (required if email services are to be enabled) | |
| SMTP_USER | Username for your SMTP Server. | optional (required if email services are to be enabled) | |

View File

@@ -33,6 +33,7 @@ To enable email functionality, configure the following environment variables:
```bash
# Basic SMTP Configuration
MAIL_FROM=noreply@yourdomain.com
MAIL_FROM_NAME=Formbricks
SMTP_HOST=smtp.yourprovider.com
SMTP_PORT=587
SMTP_USER=your_username
@@ -75,6 +76,7 @@ If you're using the one-click setup with Docker Compose, you can either:
environment:
# Email Configuration
MAIL_FROM: noreply@yourdomain.com
MAIL_FROM_NAME: Formbricks
SMTP_HOST: smtp.yourprovider.com
SMTP_PORT: 587
SMTP_USER: your_username
@@ -95,6 +97,7 @@ environment:
```bash
MAIL_FROM=noreply@yourdomain.com
MAIL_FROM_NAME=Formbricks
SMTP_HOST=smtp.sendgrid.net
SMTP_PORT=587
SMTP_USER=apikey
@@ -105,6 +108,7 @@ SMTP_PASSWORD=your_sendgrid_api_key
```bash
MAIL_FROM=noreply@yourdomain.com
MAIL_FROM_NAME=Formbricks
SMTP_HOST=email-smtp.us-east-1.amazonaws.com
SMTP_PORT=587
SMTP_USER=your_ses_access_key
@@ -115,6 +119,7 @@ SMTP_PASSWORD=your_ses_secret_key
```bash
MAIL_FROM=your_email@gmail.com
MAIL_FROM_NAME=Formbricks
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_USER=your_email@gmail.com

View File

@@ -83,6 +83,7 @@ export const SMTP_PASSWORD = env.SMTP_PASSWORD;
export const SMTP_AUTHENTICATED = env.SMTP_AUTHENTICATED !== "0";
export const SMTP_REJECT_UNAUTHORIZED_TLS = env.SMTP_REJECT_UNAUTHORIZED_TLS !== "0";
export const MAIL_FROM = env.MAIL_FROM;
export const MAIL_FROM_NAME = env.MAIL_FROM_NAME;
export const NEXTAUTH_SECRET = env.NEXTAUTH_SECRET;
export const ITEMS_PER_PAGE = 30;

View File

@@ -49,6 +49,7 @@ export const env = createEnv({
INTERCOM_SECRET_KEY: z.string().optional(),
IS_FORMBRICKS_CLOUD: z.enum(["1", "0"]).optional(),
MAIL_FROM: z.string().email().optional(),
MAIL_FROM_NAME: z.string().optional(),
NEXTAUTH_SECRET: z.string().min(1),
NOTION_OAUTH_CLIENT_ID: z.string().optional(),
NOTION_OAUTH_CLIENT_SECRET: z.string().optional(),
@@ -173,6 +174,7 @@ export const env = createEnv({
INTERCOM_SECRET_KEY: process.env.INTERCOM_SECRET_KEY,
IS_FORMBRICKS_CLOUD: process.env.IS_FORMBRICKS_CLOUD,
MAIL_FROM: process.env.MAIL_FROM,
MAIL_FROM_NAME: process.env.MAIL_FROM_NAME,
NEXTAUTH_SECRET: process.env.NEXTAUTH_SECRET,
NEXT_PUBLIC_FORMBRICKS_API_HOST: process.env.NEXT_PUBLIC_FORMBRICKS_API_HOST,
NEXT_PUBLIC_FORMBRICKS_ENVIRONMENT_ID: process.env.NEXT_PUBLIC_FORMBRICKS_ENVIRONMENT_ID,

View File

@@ -119,6 +119,7 @@
"IS_FORMBRICKS_CLOUD",
"INTERCOM_SECRET_KEY",
"MAIL_FROM",
"MAIL_FROM_NAME",
"NEXT_PUBLIC_LAYER_API_KEY",
"NEXT_PUBLIC_DOCSEARCH_APP_ID",
"NEXT_PUBLIC_DOCSEARCH_API_KEY",