diff --git a/frontend/src/lib/email.ts b/frontend/src/lib/email.ts index 0ad9877..047a0fa 100644 --- a/frontend/src/lib/email.ts +++ b/frontend/src/lib/email.ts @@ -7,16 +7,15 @@ const forceProduction = import.meta.env.PB_POCKETBASE_URL?.includes('avt-back') const isProduction = hasProductionFlag || forceProduction || !isDev; const SMTP_HOST = isProduction - ? (import.meta.env.SMTP_HOST || 'smtp.resend.com') + ? (import.meta.env.SMTP_HOST || 'smtp.yandex.ru') : 'localhost'; const SMTP_PORT = isProduction ? (import.meta.env.SMTP_PORT || '587') : '1025'; const SMTP_AUTH_USER = isProduction ? (import.meta.env.SMTP_AUTH_USER || '') : ''; const SMTP_AUTH_PASS = isProduction ? (import.meta.env.SMTP_AUTH_PASS || '') : ''; -const RESEND_API_KEY = import.meta.env.RESEND_API_KEY || SMTP_AUTH_PASS; const FROM_EMAIL = isProduction - ? (import.meta.env.FROM_EMAIL || 'onboarding@resend.onlinemail.me') + ? (import.meta.env.FROM_EMAIL || 'noreply@localhost') : 'noreply@localhost'; const FROM_NAME = isProduction ? (import.meta.env.FROM_NAME || 'Автоюрист Сургут') : 'Dev'; const SITE_URL = isProduction @@ -26,11 +25,8 @@ const SITE_URL = isProduction let transporter: nodemailer.Transporter | null = null; console.log('[EMAIL] isDev:', isDev); -console.log('[EMAIL] hasProductionFlag:', hasProductionFlag); -console.log('[EMAIL] forceProduction:', forceProduction); console.log('[EMAIL] isProduction:', isProduction); -console.log('[EMAIL] RESEND_API_KEY present:', !!RESEND_API_KEY); -console.log('[EMAIL] Use RESEND_API:', isProduction && !!RESEND_API_KEY); +console.log('[EMAIL] SMTP:', SMTP_HOST, ':', SMTP_PORT); function getTransporter() { if (!transporter) { @@ -94,12 +90,8 @@ function withTimeout(promise: Promise, ms: number): Promise { } export async function sendEmail(options: EmailOptions): Promise { - if (isProduction && RESEND_API_KEY) { - return sendViaResendApi(options); - } - console.log('[NODEMAILER] Sending to:', options.to); - console.log('[NODEMAILER] SMTP config:', { host: SMTP_HOST, port: SMTP_PORT }); + console.log('[NODEMAILER] SMTP config:', { host: SMTP_HOST, port: SMTP_PORT, user: SMTP_AUTH_USER }); try { const info = await withTimeout(