Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

448
Vistas
Nodemailer not working when used with Firebase Functions

I'm trying to send myself an email when a new user account is made in my web app. Here is the current code I'm deploying to Firebase Functions:

const functions = require("firebase-functions");
const admin = require("firebase-admin");
const nodemailer = require("nodemailer");

admin.initializeApp();

require("dotenv").config();

const {
    SENDER_EMAIL,
    SENDER_PASSWORD
} = process.env;

exports.sendEmailNotification = functions.firestore.document("users/{userId}").onCreate(async (snapshot, context) => {
    const data = snapshot.data();

    // create reusable transporter object using the default SMTP transport
    let transporter = nodemailer.createTransport({
        host: "smtp.gmail.com",
        port: 465,
        secure: true,
        auth: {
            user: SENDER_EMAIL,
            pass: SENDER_PASSWORD,
        },
    });

    // send mail with defined transport object
    let info = await transporter.sendMail({
        from: `"MY_APP_NAME" <${SENDER_EMAIL}>`,
        to: "MY_PERSONAL_GMAIL_ACCOUNT",
        subject: `A New User Has Joined MY_APP_NAME!`,
        text: `A new user has joined MY_APP_NAME. Name: ${data.name}, email: ${data.email}`
    });
})

Running a similar version on my machine using the node index.js command works no problem. The problem seems to be when it runs on Firebase Functions.

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

According to your current code, it seems to be working correctly, as you said, it only works fine in your machine using the node.js. Probably the guide to follow to get the same result is the Nodemailer as a module for Node.js.

Now, if you would like to do it using Cloud Functions for Firebase, I can highly recommend you to follow the Send Email Using Firebase Functions & Nodemailer guide.

Additional guide for Send Email with Firebase functions and Nodemailer.

about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda