Новые правки
This commit is contained in:
parent
2453421cdf
commit
35aeeca9a2
1 changed files with 4 additions and 12 deletions
|
|
@ -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<T>(promise: Promise<T>, ms: number): Promise<T> {
|
|||
}
|
||||
|
||||
export async function sendEmail(options: EmailOptions): Promise<boolean> {
|
||||
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(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue