From 65194dd059e5b65511f4aa9954eda1311014d133 Mon Sep 17 00:00:00 2001 From: Anatoli Nicolae Date: Sun, 7 Jan 2024 15:15:45 +0100 Subject: [PATCH] Allow FROM customization Allow custom FROM value for emails not to be marked as spam for mismatched domain. Signed-off-by: Anatoli Nicolae --- .env.example | 1 + app/utils/env.ts | 2 ++ app/utils/mail.server.ts | 4 ++-- docs/get-started.md | 1 + 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.env.example b/.env.example index f0111f51d..43d096f8a 100644 --- a/.env.example +++ b/.env.example @@ -9,6 +9,7 @@ SERVER_URL="http://localhost:3000" SMTP_PWD="super-safe-passw0rd" SMTP_HOST="mail.shelf.nu" SMTP_USER="no-reply@shelf.nu" +SMTP_FROM="Shelf " MAPTILER_TOKEN="maptiler-token" MICROSOFT_CLARITY_ID="microsoft-clarity-id" diff --git a/app/utils/env.ts b/app/utils/env.ts index e9214715e..11c811c62 100644 --- a/app/utils/env.ts +++ b/app/utils/env.ts @@ -37,6 +37,7 @@ declare global { SMTP_PWD: string; SMTP_HOST: string; SMTP_USER: string; + SMTP_FROM: string; MAINTENANCE_MODE: string; GEOCODE_API_KEY: string; } @@ -80,6 +81,7 @@ export const STRIPE_SECRET_KEY = getEnv("STRIPE_SECRET_KEY", { export const SMTP_PWD = getEnv("SMTP_PWD"); export const SMTP_HOST = getEnv("SMTP_HOST"); export const SMTP_USER = getEnv("SMTP_USER"); +export const SMTP_FROM = getEnv("SMTP_FROM"); /** * Shared envs diff --git a/app/utils/mail.server.ts b/app/utils/mail.server.ts index 0c6628f38..96f5dc40f 100644 --- a/app/utils/mail.server.ts +++ b/app/utils/mail.server.ts @@ -1,5 +1,5 @@ import nodemailer from "nodemailer"; -import { NODE_ENV, SMTP_HOST, SMTP_PWD, SMTP_USER } from "."; +import { NODE_ENV, SMTP_HOST, SMTP_PWD, SMTP_USER, SMTP_FROM } from "."; export const sendEmail = async ({ to, @@ -40,7 +40,7 @@ export const sendEmail = async ({ // send mail with defined transport object await transporter.sendMail({ - from: '"Shelf.nu" ', // sender address + from: SMTP_FROM || '"Shelf.nu" ', // sender address to, // list of receivers subject, // Subject line text, // plain text body diff --git a/docs/get-started.md b/docs/get-started.md index 101e8f371..9c5bca9dd 100644 --- a/docs/get-started.md +++ b/docs/get-started.md @@ -49,6 +49,7 @@ MAPTILER_TOKEN="someToken" SMTP_HOST="smtp.yourhost.com" SMTP_USER="you@example.com" SMTP_PWD="yourSMTPpassword" +SMTP_FROM="Shelf " ``` - This step only applies if you've opted out of having the CLI install dependencies for you: