Новые правки

This commit is contained in:
Web-serfer 2026-05-04 02:45:06 +05:00
parent 2391a3c7d6
commit ec1826801f

View file

@ -2,20 +2,23 @@ import nodemailer from 'nodemailer';
import type { EmailOptions } from '../globalInterfaces'; import type { EmailOptions } from '../globalInterfaces';
const isDev = import.meta.env.DEV; const isDev = import.meta.env.DEV;
const isProduction = import.meta.env.PROD === 'true' || !isDev;
const SMTP_HOST = isDev const SMTP_HOST = isProduction
? 'localhost' ? (import.meta.env.SMTP_HOST || 'smtp.resend.com')
: (import.meta.env.SMTP_HOST || 'smtp.gmail.com'); : 'localhost';
const SMTP_PORT = isDev const SMTP_PORT = isProduction
? '1025' ? (import.meta.env.SMTP_PORT || '465')
: (import.meta.env.SMTP_PORT || '465'); : '1025';
const SMTP_AUTH_USER = import.meta.env.SMTP_AUTH_USER || ''; const SMTP_AUTH_USER = isProduction ? (import.meta.env.SMTP_AUTH_USER || '') : '';
const SMTP_AUTH_PASS = import.meta.env.SMTP_AUTH_PASS || ''; const SMTP_AUTH_PASS = isProduction ? (import.meta.env.SMTP_AUTH_PASS || '') : '';
const FROM_EMAIL = import.meta.env.FROM_EMAIL || 'noreply@localhost'; const FROM_EMAIL = isProduction
const FROM_NAME = import.meta.env.FROM_NAME || 'Dev'; ? (import.meta.env.FROM_EMAIL || 'onboarding@resend.onlinemail.me')
const SITE_URL = isDev : 'noreply@localhost';
? 'http://localhost:4321' const FROM_NAME = isProduction ? (import.meta.env.FROM_NAME || 'Автоюрист Сургут') : 'Dev';
: (import.meta.env.SITE_URL || 'https://avtourist-surgut.ru'); const SITE_URL = isProduction
? (import.meta.env.SITE_URL || 'https://avtourist-surgut.ru')
: 'http://localhost:4321';
let transporter: nodemailer.Transporter | null = null; let transporter: nodemailer.Transporter | null = null;
@ -24,12 +27,12 @@ function getTransporter() {
transporter = nodemailer.createTransport({ transporter = nodemailer.createTransport({
host: SMTP_HOST, host: SMTP_HOST,
port: parseInt(SMTP_PORT), port: parseInt(SMTP_PORT),
secure: !isDev, secure: isProduction,
requireTLS: !isDev, requireTLS: isProduction,
auth: isDev ? undefined : { auth: isProduction && SMTP_AUTH_USER ? {
user: SMTP_AUTH_USER, user: SMTP_AUTH_USER,
pass: SMTP_AUTH_PASS, pass: SMTP_AUTH_PASS,
}, } : undefined,
}); });
} }
return transporter; return transporter;