Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template to send emails #15

Merged
merged 1 commit into from
Sep 21, 2024
Merged

Conversation

phamkelly17
Copy link
Collaborator

Notion ticket link

Email Reminders

Implementation description

  • Use NodeMailer to be able to send emails
  • Implemented unstyled template that allows us to send emails

Steps to test

  1. Go to http://localhost:3000/email
  2. Add recipients to the first text input. If you want to send to multiple emails, split them using a comma with no space after the comma. (e.g. "kellypham@uwblueprint.org, jasonling@uwblueprint.org")
  3. Add the email body to the textbox
  4. Click send
  5. Check your email and you should have received an email from kellypham@uwblueprint.org

What should reviewers focus on?

  • functionality

Checklist

  • My PR name is descriptive and in imperative tense
  • My commit messages are descriptive and in imperative tense. My commits are atomic and trivial commits are squashed or fixup'd into non-trivial commits
  • I have run the appropriate linter(s)
  • I have requested a review from the PL, as well as other devs who have background knowledge on this PR or who will be building on top of this PR

@phamkelly17 phamkelly17 marked this pull request as ready for review June 27, 2024 23:11
package.json Outdated Show resolved Hide resolved
const transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: ['kellypham@uwblueprint.org'],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would put these variables in the .env file instead of hardcoding them.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please contact me to put the email / password in the hashicorp vault. I feel like we should probably use the sistema email instead of kelly's so let me know when you would like to set that up!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

tsconfig.json Outdated Show resolved Hide resolved
@ChinemeremChigbo
Copy link
Member

Please add the following to the .env.sample file:

EMAIL_PASS=
EMAIL_SERVICE=
EMAIL_USER=

tsconfig.json Outdated
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "es5",
"target": "es2017",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would just change this back to es5. Other than that, LGTM.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you change it back lol.

@phamkelly17 phamkelly17 requested review from d282liu and ludavidca and removed request for d282liu July 13, 2024 18:16
@RahulTandon1
Copy link
Collaborator

RahulTandon1 commented Jul 14, 2024

@ChinemeremChigbo could you please help me understand the ticket a bit more.

To the best of my understanding, we're trying to do the following:
Whenever an absence is created/claimed (or edited in any important way), we want to notify all relevant users with an email.

The email follows a template. Example :

// not this does not follow the DB schemas. I'm just made the fields up.

Hey {user.firstName}!
The absence for the class {absence.class}  on `absence.date` has been claimed by {user2.firstName} {user2.lastName}.
More text...

The Sistema Toronto Team

Q1: In the long term / actual product we want the admin to be able to modify this template through a GUI...right?
Q2: The main point of this ticket is to get the email sending functionality up and running...right?
Q3: if there's anything you think is wrong with my understanding, could you please correct it?

Copy link
Collaborator

@RahulTandon1 RahulTandon1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's really cool that you were able to get this running with such succinct code. I was expecting NodeMailer to be really tough to get working, but you made it look like easy like a pro dev :-)

src/pages/api/sendEmail.ts Show resolved Hide resolved
src/pages/email.tsx Show resolved Hide resolved
src/pages/email.tsx Outdated Show resolved Hide resolved
},
body: JSON.stringify({
to: emailRecipients,
subject: 'Hello World',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add another Input/TextArea in the form and get the subject from there?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

src/pages/api/sendEmail.ts Show resolved Hide resolved
src/pages/email.tsx Show resolved Hide resolved
@phamkelly17
Copy link
Collaborator Author

@RahulTandon1 to answer your questions:
Q1: I thought the email would be a generic message like "Hi name, we see you haven't uploaded your lesson plan for your lesson in num days. Sincerely, Sistema". So I didn't think the template would be configurable.
Q2: Correct, this ticket is solely for functionality

@ChinemeremChigbo
Copy link
Member

@ChinemeremChigbo could you please help me understand the ticket a bit more.

To the best of my understanding, we're trying to do the following: Whenever an absence is created/claimed (or edited in any important way), we want to notify all relevant users with an email.

The email follows a template. Example :

// not this does not follow the DB schemas. I'm just made the fields up.

Hey {user.firstName}!
The absence for the class {absence.class}  on `absence.date` has been claimed by {user2.firstName} {user2.lastName}.
More text...

The Sistema Toronto Team

Q1: In the long term / actual product we want the admin to be able to modify this template through a GUI...right? Q2: The main point of this ticket is to get the email sending functionality up and running...right? Q3: if there's anything you think is wrong with my understanding, could you please correct it?

  1. Yes
  2. Yes
  3. There's nothing to correct

Copy link
Collaborator

@RahulTandon1 RahulTandon1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're good to ship.
Sorry for all my delays Kelly.
Thank you!

src/pages/api/sendEmail.ts Show resolved Hide resolved
Copy link

vercel bot commented Sep 21, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sistema ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 21, 2024 8:56pm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants