Skip to content

Commit

Permalink
Allow FROM customization
Browse files Browse the repository at this point in the history
Allow custom FROM value for emails not to be marked as spam for mismatched domain.

Signed-off-by: Anatoli Nicolae <[email protected]>
  • Loading branch information
anatolinicolae committed Jan 7, 2024
1 parent 5454410 commit 65194dd
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ SERVER_URL="http://localhost:3000"
SMTP_PWD="super-safe-passw0rd"
SMTP_HOST="mail.shelf.nu"
SMTP_USER="[email protected]"
SMTP_FROM="Shelf <[email protected]>"

MAPTILER_TOKEN="maptiler-token"
MICROSOFT_CLARITY_ID="microsoft-clarity-id"
Expand Down
2 changes: 2 additions & 0 deletions app/utils/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions app/utils/mail.server.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -40,7 +40,7 @@ export const sendEmail = async ({

// send mail with defined transport object
await transporter.sendMail({
from: '"Shelf.nu" <[email protected]>', // sender address
from: SMTP_FROM || '"Shelf.nu" <[email protected]>', // sender address
to, // list of receivers
subject, // Subject line
text, // plain text body
Expand Down
1 change: 1 addition & 0 deletions docs/get-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ MAPTILER_TOKEN="someToken"
SMTP_HOST="smtp.yourhost.com"
SMTP_USER="[email protected]"
SMTP_PWD="yourSMTPpassword"
SMTP_FROM="Shelf <[email protected]>"
```

- This step only applies if you've opted out of having the CLI install dependencies for you:
Expand Down

0 comments on commit 65194dd

Please sign in to comment.