This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const admin = require('firebase-admin'); | |
const sendEmail = require('./sendEmail'); // doesn't exist yet | |
admin.initializeApp(); | |
exports.sendEmail = sendEmail; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { https } = require('firebase-functions'); | |
const sendEmail = https.onRequest((req, res) => { | |
res.send({ status: 200 }); | |
}); | |
module.exports = sendEmail; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { https } = require('firebase-functions'); | |
const { createTransport } = require('nodemailer'); | |
const sender = '<THE_EMAIL_YOU_JUST_CREATED'; | |
const password = '<THE_PASSWORD_YOU_JUST_CREATED>'; | |
const recipient = '<THE_EMAIL_YOU_ARE_SENDING_TO>'; | |
const transporter = createTransport({ | |
service: 'gmail', | |
auth: { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
firebase functions:config:set gmail.sender=<YOUR_EMAIL> gmail.password=<YOUR_PASSWORD> gmail.recipient=<TO_EMAIL> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { | |
gmail: { password, recipient, sender }, | |
} = config(); | |
const transporter = createTransport({ | |
service: 'gmail', | |
auth: { | |
user: sender, | |
pass: password, | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const mailOptions = ({ subject, name, message }) => { | |
const text = ` | |
Name: ${name} | |
Message: ${message} | |
`; | |
const html = ` | |
<h1>Name: ${name}</h1> | |
<p>Message: ${message}</p> | |
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Axios from 'axios'; | |
import React, { useState } from 'react'; | |
const sendEmailURL = '<YOUR_FUNCTION_URL>'; | |
function App() { | |
const [state, setState] = useState({ | |
message: '', | |
name: '', | |
subject: '', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const cors = require('cors'); | |
const corsHandler = cors({ origin: true }); | |
/* Your other code */ | |
const handleEmail = (req, res) => { | |
corsHandler(req, res, () => { | |
transporter.sendMail(mailOptions(req.query), transport); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const a = [1, 2, 4] | |
forEach(console.log, a) | |
// [1, 2, 4] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
// ...other fields | |
"name": "slack", | |
"publicName": "Slack" | |
"author": "Slack Inc." | |
"build": { | |
"appId": "com.slack.desktop", | |
"copyright": "Copyright 2020 Slack" | |
} | |
// ...other fields |
OlderNewer