Skip to content

Commit

Permalink
Merge pull request #65 from foyzulkarim/feature/send-email
Browse files Browse the repository at this point in the history
Introduced sendgrid
  • Loading branch information
foyzulkarim authored Mar 30, 2022
2 parents 72b682f + 0f684be commit d4137d4
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 9 deletions.
1 change: 1 addition & 0 deletions server/.env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ JWT_EXPIRES_IN=100
PORT=5000
IS_MONGODB_CLOUD_URL=false
MONGODB_CLOUD_URL=mongodb+srv:// <USER >: <PASSWORD >@cluster0.abcd.mongodb.net/myFirstDatabase?retryWrites=true
SENDGRID_API_KEY=123
96 changes: 87 additions & 9 deletions server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"@sendgrid/mail": "^7.6.2",
"bcrypt": "^5.0.1",
"compression": "^1.7.4",
"cors": "^2.8.5",
Expand Down
18 changes: 18 additions & 0 deletions server/src/email/sendgrid.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const sgMail = require("@sendgrid/mail");

sgMail.setApiKey(process.env.SENDGRID_API_KEY);
const msg = {
to: "foyzulkarim@gmail.com", // Change to your recipient
from: "info@bizbook365.com", // Change to your verified sender
subject: "Sending with SendGrid is Fun",
text: "and easy to do anywhere, even with Node.js",
html: "<strong>and easy to do anywhere, even with Node.js</strong>",
};
sgMail
.send(msg)
.then(() => {
console.log("Email sent");
})
.catch((error) => {
console.error(error);
});

0 comments on commit d4137d4

Please sign in to comment.