From ec1826801fe295eb45812e8a1f1426f4f6bea3b3 Mon Sep 17 00:00:00 2001 From: Web-serfer Date: Mon, 4 May 2026 02:45:06 +0500 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=BE=D0=B2=D1=8B=D0=B5=20=D0=BF=D1=80?= =?UTF-8?q?=D0=B0=D0=B2=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/lib/email.ts | 37 ++++++++++++++++++++----------------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/frontend/src/lib/email.ts b/frontend/src/lib/email.ts index c02a5d0..d8f10a7 100644 --- a/frontend/src/lib/email.ts +++ b/frontend/src/lib/email.ts @@ -2,20 +2,23 @@ import nodemailer from 'nodemailer'; import type { EmailOptions } from '../globalInterfaces'; const isDev = import.meta.env.DEV; +const isProduction = import.meta.env.PROD === 'true' || !isDev; -const SMTP_HOST = isDev - ? 'localhost' - : (import.meta.env.SMTP_HOST || 'smtp.gmail.com'); -const SMTP_PORT = isDev - ? '1025' - : (import.meta.env.SMTP_PORT || '465'); -const SMTP_AUTH_USER = import.meta.env.SMTP_AUTH_USER || ''; -const SMTP_AUTH_PASS = import.meta.env.SMTP_AUTH_PASS || ''; -const FROM_EMAIL = import.meta.env.FROM_EMAIL || 'noreply@localhost'; -const FROM_NAME = import.meta.env.FROM_NAME || 'Dev'; -const SITE_URL = isDev - ? 'http://localhost:4321' - : (import.meta.env.SITE_URL || 'https://avtourist-surgut.ru'); +const SMTP_HOST = isProduction + ? (import.meta.env.SMTP_HOST || 'smtp.resend.com') + : 'localhost'; +const SMTP_PORT = isProduction + ? (import.meta.env.SMTP_PORT || '465') + : '1025'; +const SMTP_AUTH_USER = isProduction ? (import.meta.env.SMTP_AUTH_USER || '') : ''; +const SMTP_AUTH_PASS = isProduction ? (import.meta.env.SMTP_AUTH_PASS || '') : ''; +const FROM_EMAIL = isProduction + ? (import.meta.env.FROM_EMAIL || 'onboarding@resend.onlinemail.me') + : 'noreply@localhost'; +const FROM_NAME = isProduction ? (import.meta.env.FROM_NAME || 'Автоюрист Сургут') : 'Dev'; +const SITE_URL = isProduction + ? (import.meta.env.SITE_URL || 'https://avtourist-surgut.ru') + : 'http://localhost:4321'; let transporter: nodemailer.Transporter | null = null; @@ -24,12 +27,12 @@ function getTransporter() { transporter = nodemailer.createTransport({ host: SMTP_HOST, port: parseInt(SMTP_PORT), - secure: !isDev, - requireTLS: !isDev, - auth: isDev ? undefined : { + secure: isProduction, + requireTLS: isProduction, + auth: isProduction && SMTP_AUTH_USER ? { user: SMTP_AUTH_USER, pass: SMTP_AUTH_PASS, - }, + } : undefined, }); } return transporter;