Новые правки

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';
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;