Skip to content

Instantly share code, notes, and snippets.

Created Apr 14, 2017
What would you like to do?
Belajar Firebase Functions: Kirim Email dari Contact Form
var functions = require('firebase-functions');
var nodemailer = require('nodemailer');
// Setting email dan password pengirim
const gmailEmail = '';
const gmailPass = '';
const mailer = nodemailer.createTransport({
service: 'Gmail',
auth: {user: gmailEmail, pass: gmailPass}
// Mendefinisikan fungsi dengan HTTP trigger
exports.sendEmail = functions.https.onRequest(function (req, res) {
var text = [
'Pengirim: ',
'Subjek: '+req.body.subject,
'Pesan: '+req.body.message
var message = {
to: gmailEmail,
subject: 'Pesan baru dari contact form: '+req.body.subject,
text: text.join("\n")
return mailer.sendMail(message).then(function () {
res.send('Email terkirim!');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment