From b2ce341ef1e5e2472f6cdeeff1d2a14f51380aeb Mon Sep 17 00:00:00 2001 From: dscadmin Date: Wed, 30 Apr 2025 11:49:47 -0600 Subject: [PATCH] =?UTF-8?q?Cambio=20a=20c=C3=B3digo=20en=20archivo=20serve?= =?UTF-8?q?r/helper/gmail.js=20para=20env=C3=ADo=20de=20correos=20con=20Re?= =?UTF-8?q?lay=20SMTP?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/helper/gmail.js | 61 +++++++----------------------------------- 1 file changed, 10 insertions(+), 51 deletions(-) diff --git a/server/helper/gmail.js b/server/helper/gmail.js index 69a9198..d5f3fc3 100644 --- a/server/helper/gmail.js +++ b/server/helper/gmail.js @@ -1,60 +1,19 @@ -/* require('../config/config'); - -const send = require('gmail-send')({ - user: process.env.GMAIL, - pass: process.env.GMAILPASSWORD, -}); - -const gmail = (subject, to, text) => { - - return new Promise((resolve, reject) => { - send({ subject, to, text }, (error, result, fullResult) => { - if (error) reject(error); - resolve(result); - }); - }); - - - // return "envio de correo" - - -}; - -module.exports = gmail; - */ - - - - -// src/utils/gmail.js (o donde prefieras) -// gmail.js (o el nombre que prefieras) require('../config/config'); // mantiene tu carga de variables const nodemailer = require('nodemailer'); -// Transporter con pooling y throttling const transporter = nodemailer.createTransport({ - host: 'smtp.gmail.com', // cambia a smtp-relay.gmail.com si usas Workspace - port: 587, - secure: false, // STARTTLS en puerto 587 - requireTLS: true, - auth: { - user: process.env.USER_GMAIL, // ejemplo: tu-cuenta@gmail.com - pass: process.env.PASS_GMAIL, // App-Password de 16 caracteres - }, - pool: true, // reutiliza la conexión - maxConnections: 1, // una conexión simultánea - maxMessages: 100, // reabre después de 100 envíos - rateDelta: 2000, // ventana de 2 s - rateLimit: 1, // máx. 1 mensaje por ventana (≈ 0.5 msg/s) + host: 'smtp-relay.gmail.com', + port: 587, + secure: false, + requireTLS: true, + name: 'acatlan.unam.mx', + pool: true, + maxConnections: 1, + maxMessages: 100, + rateDelta: 2000, + rateLimit: 1, }); -/** - * Envía un correo (API idéntica a tu versión anterior). - * @param {string} subject Asunto - * @param {string|string[]} to Destinatario(s) - * @param {string} text Cuerpo en texto plano - * @return {Promise} info de nodemailer - */ const gmail = (subject, to, text) => transporter.sendMail({ from: process.env.USER_GMAIL,