forked from cloudinary-devs/cloudybadge
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix cloudinary-devs#9 enable sending email
- Loading branch information
Maya Shavin
committed
Feb 4, 2020
1 parent
2401780
commit 9d70917
Showing
10 changed files
with
369 additions
and
44 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,4 +83,5 @@ dist | |
|
||
# Service worker | ||
sw.* | ||
now.json | ||
now.json | ||
.demo.js |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,31 @@ | ||
const nodemailer = require('nodemailer'); | ||
|
||
const transporter = nodemailer.createTransport({ | ||
service: 'gmail', | ||
auth: { | ||
user: process.env.EMAIL_USER, | ||
pass: process.env.EMAIL_KEY | ||
} | ||
}); | ||
|
||
const mailOptions = { | ||
from: process.env.EMAIL_USER, | ||
subject: 'Start editing your badge with CloudyBadge', | ||
text: 'Testing' | ||
const sgMail = require('@sendgrid/mail') | ||
sgMail.setApiKey(process.env.SENDGRID_API_KEY); | ||
const fromEmail = process.env.SENDGRID_EMAIL; | ||
const templates = { | ||
registerSuccess: process.env.SENDGRID_TEMPLATE_REGISTER | ||
}; | ||
|
||
module.exports = (user) => { | ||
const options = { | ||
...mailOptions, | ||
module.exports = async (user, eventName) => { | ||
const content = { | ||
to: user.email, | ||
}; | ||
|
||
transporter.sendMail(options, (error, info) => { | ||
if (error) { | ||
console.log(error) | ||
} else { | ||
console.log('Email sent: ' + info.response); | ||
from: { | ||
email: fromEmail, | ||
name: 'Cloudinary Demo' | ||
}, | ||
templateId: templates.registerSuccess, | ||
dynamic_template_data: { | ||
name: user.firstName, | ||
vote_id: user.voteID, | ||
edit_id: user.editKey, | ||
event_id: user.eventId, | ||
event: eventName | ||
} | ||
}); | ||
} | ||
|
||
try { | ||
await sgMail.send(content) | ||
console.log('Message sent successfully.') | ||
} catch (error) { | ||
console.log('Message not sent.') | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<template> | ||
<svg :width="size" :height="size" aria-hidden="true" focusable="false" role="img" viewBox="0 0 24 24"> | ||
<path fill="#fff" d="M34.52 239.03L228.87 44.69c9.37-9.37 24.57-9.37 33.94 0l22.67 22.67c9.36 9.36 9.37 24.52.04 33.9L131.49 256l154.02 154.75c9.34 9.38 9.32 24.54-.04 33.9l-22.67 22.67c-9.37 9.37-24.57 9.37-33.94 0L34.52 272.97c-9.37-9.37-9.37-24.57 0-33.94z"/> | ||
</svg> | ||
</template> |
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export const icons = { | ||
save: "M17 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V7l-4-4zm-5 16c-1.66 0-3-1.34-3-3s1.34-3 3-3 3 1.34 3 3-1.34 3-3 3zm3-10H5V5h10v4z", | ||
load: 'M12 4V1L8 5l4 4V6c3.31 0 6 2.69 6 6 0 1.01-.25 1.97-.7 2.8l1.46 1.46C19.54 15.03 20 13.57 20 12c0-4.42-3.58-8-8-8zm0 14c-3.31 0-6-2.69-6-6 0-1.01.25-1.97.7-2.8L5.24 7.74C4.46 8.97 4 10.43 4 12c0 4.42 3.58 8 8 8v3l4-4-4-4v3z', | ||
back: 'M34.52 239.03L228.87 44.69c9.37-9.37 24.57-9.37 33.94 0l22.67 22.67c9.36 9.36 9.37 24.52.04 33.9L131.49 256l154.02 154.75c9.34 9.38 9.32 24.54-.04 33.9l-22.67 22.67c-9.37 9.37-24.57 9.37-33.94 0L34.52 272.97c-9.37-9.37-9.37-24.57 0-33.94z', | ||
}; | ||
|
||
export default icons; |
Oops, something went wrong.