Skip to content

Commit

Permalink
added email invite
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlwn123 committed May 7, 2022
1 parent b0d72e0 commit 9680f22
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
30 changes: 30 additions & 0 deletions backend/mailgun/mailgun.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const mailgun = require("mailgun-js");
const DOMAIN = "sandboxb488ae9cba904e73936d81f35b2ee781.mailgun.org";
const mg = mailgun({
apiKey: "d05c4d067d69c940d3dac93769dd87a2-fe066263-f6136332",
domain: DOMAIN
});

const sendInvite = async (newUser, email, familyName, inviteLink) => {
const data = {
from: "Mailgun Sandbox <[email protected]>",
to: email,
subject: "Welcome to BTC Family!",
text:
`Hi ${newUser},
You are invited to join the ${familyName} family wallet!
Click here: ${inviteLink} to accept your invitation!
`
};

await mg.messages().send(data, function (error, body) {
if (error) {
console.error("Invite failed:", error)
} else {
console.log("Invite success:", body);
}
});
}

export { sendInvite }
1 change: 1 addition & 0 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"express": "^4.17.3",
"firebase-admin": "^10.0.2",
"http-errors": "^2.0.0",
"mailgun-js": "^0.22.0",
"morgan": "^1.10.0",
"nodemon": "^2.0.15",
"opennode": "^1.3.0",
Expand Down

0 comments on commit 9680f22

Please sign in to comment.