Новые изменения в систему регистрации

This commit is contained in:
Web-serfer 2026-05-04 02:42:45 +05:00
parent d69a7acd5a
commit 2391a3c7d6
2 changed files with 32 additions and 21 deletions

View file

@ -1,11 +1,21 @@
import nodemailer from 'nodemailer';
import type { EmailOptions } from '../globalInterfaces';
const SMTP_HOST = import.meta.env.SMTP_HOST; // || 'localhost';
const SMTP_PORT = import.meta.env.SMTP_PORT; // || 1025;
const FROM_EMAIL = import.meta.env.FROM_EMAIL; // || 'noreply@avtourist-surgut.ru';
const FROM_NAME = import.meta.env.FROM_NAME; // || 'Автоюрист Сургут';
const SITE_URL = import.meta.env.SITE_URL; // || 'http://localhost:4321';
const isDev = import.meta.env.DEV;
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');
let transporter: nodemailer.Transporter | null = null;
@ -13,9 +23,13 @@ function getTransporter() {
if (!transporter) {
transporter = nodemailer.createTransport({
host: SMTP_HOST,
port: parseInt(String(SMTP_PORT)),
secure: false,
ignoreTLS: true,
port: parseInt(SMTP_PORT),
secure: !isDev,
requireTLS: !isDev,
auth: isDev ? undefined : {
user: SMTP_AUTH_USER,
pass: SMTP_AUTH_PASS,
},
});
}
return transporter;