# Sending email notifications from the SchoalrX platform

**URL:** <https://sef.discourse.group/t/sending-email-notifications-from-the-schoalrx-platform/247>\
**Category:** ScholarX\
**Created:** [April 9, 2021, 7:17am UTC](https://sef.discourse.group/t/sending-email-notifications-from-the-schoalrx-platform/247 "2021-04-09T07:17:17Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![jaye](https://yyz2.discourse-cdn.com/free1/user_avatar/sef.discourse.group/jaye/32/810_2.png) [@jaye](https://sef.discourse.group/u/jaye)\
**Post date:** [April 9, 2021, 7:17am UTC](https://sef.discourse.group/t/sending-email-notifications-from-the-schoalrx-platform/247/1 "2021-04-09T07:17:17Z")

</div>

Sending email notifications is a functional requirement of the ScholarX Platform.  
@YohanAvishke @Gravewalker @piumal1999 Do you already have any plan on implementation?  
I just went through some available Email APIs and came up with the following findings:

1. **Sendgrid**  
Free quota: 100/day  
Java Library: Yes

2. **Mailgun**  
Free quota: 5000/month but valid only for 3 months  
Java Library: Yes

3. **Fapimail**  
Free quota: 100/day  
Java Library: No

Please add alternatives if you find any.

---

<div class="post-metadata">

**Author:** ![jaye](https://yyz2.discourse-cdn.com/free1/user_avatar/sef.discourse.group/jaye/32/810_2.png) [@jaye](https://sef.discourse.group/u/jaye)\
**Post date:** [April 9, 2021, 8:40am UTC](https://sef.discourse.group/t/sending-email-notifications-from-the-schoalrx-platform/247/2 "2021-04-09T08:40:29Z")

</div>

I saw [this](https://github.com/sef-global/scholarx-frontend/issues/95) issue on the frontend repo. I think the emails shouldn’t be handled from the front end, but need to send it through the backend.  
Downsides of having it on the frontend:

- A simple mistake that happens from the frontend might jam everything. (Ex. Reloading the page while sending emails)
- The mail credentials will be exposed to the frontend, which means someone can send emails as scholarX by doing some tweaks.

Usually these frontend emails clients are being used for implementations such as contact forms.

[https://github.com/sef-global/scholarx-frontend/issues/95](https://github.com/sef-global/scholarx-frontend/issues/95)

cc: @anjisvj [@EngTeam](https://sef.discourse.group/groups/engteam)

---

<div class="post-metadata">

**Author:** ![YohanAvishke](https://yyz2.discourse-cdn.com/free1/user_avatar/sef.discourse.group/yohanavishke/32/106_2.png) [@YohanAvishke](https://sef.discourse.group/u/YohanAvishke)\
**Post date:** [April 9, 2021, 8:55am UTC](https://sef.discourse.group/t/sending-email-notifications-from-the-schoalrx-platform/247/3 "2021-04-09T08:55:02Z")

</div>

+1 for @jaye’s comment. We should use `spring-boot-starter-mail` and existing APIs to complete this feature.

cc: @anjisvj

---

<div class="post-metadata">

**Author:** ![jaye](https://yyz2.discourse-cdn.com/free1/user_avatar/sef.discourse.group/jaye/32/810_2.png) [@jaye](https://sef.discourse.group/u/jaye)\
**Post date:** [April 9, 2021, 9:00am UTC](https://sef.discourse.group/t/sending-email-notifications-from-the-schoalrx-platform/247/4 "2021-04-09T09:00:58Z")

</div>

`spring-boot-starter-mail` seems better. We could use it even with Gmail! 💙

---

<div class="post-metadata">

**Author:** ![anjisvj](https://yyz2.discourse-cdn.com/free1/user_avatar/sef.discourse.group/anjisvj/32/9_2.png) [@anjisvj](https://sef.discourse.group/u/anjisvj)\
**Post date:** [April 9, 2021, 9:03am UTC](https://sef.discourse.group/t/sending-email-notifications-from-the-schoalrx-platform/247/5 "2021-04-09T09:03:48Z")

</div>

This is the one I have used but it was just to get user feedback. But it can be done with this one also. [nodemailer](https://www.npmjs.com/package/nodemailer)

---

<div class="post-metadata">

**Author:** ![jaye](https://yyz2.discourse-cdn.com/free1/user_avatar/sef.discourse.group/jaye/32/810_2.png) [@jaye](https://sef.discourse.group/u/jaye)\
**Post date:** [April 9, 2021, 9:05am UTC](https://sef.discourse.group/t/sending-email-notifications-from-the-schoalrx-platform/247/6 "2021-04-09T09:05:49Z")

</div>

Nodemailer is for NodeJS, right?

---

<div class="post-metadata">

**Author:** ![anjisvj](https://yyz2.discourse-cdn.com/free1/user_avatar/sef.discourse.group/anjisvj/32/9_2.png) [@anjisvj](https://sef.discourse.group/u/anjisvj)\
**Post date:** [April 9, 2021, 9:25am UTC](https://sef.discourse.group/t/sending-email-notifications-from-the-schoalrx-platform/247/7 "2021-04-09T09:25:43Z")

</div>

No, You can use it without NodeJs. BTW, we can use environment variable in that way we don’t have to expose our credentials

---

<div class="post-metadata">

**Author:** ![jaye](https://yyz2.discourse-cdn.com/free1/user_avatar/sef.discourse.group/jaye/32/810_2.png) [@jaye](https://sef.discourse.group/u/jaye)\
**Post date:** [April 9, 2021, 9:31am UTC](https://sef.discourse.group/t/sending-email-notifications-from-the-schoalrx-platform/247/8 "2021-04-09T09:31:08Z")

</div>

That’s interesting.  
However, the problem is whether we are sending emails from the frontend or the backend.  
PS:  
Environment variables are secure if and if only they are accessible from the backend.  
Also, we have the downsides I described earlier.

---

<div class="post-metadata">

**Author:** ![akshika47](https://yyz2.discourse-cdn.com/free1/user_avatar/sef.discourse.group/akshika47/32/993_2.png) [@akshika47](https://sef.discourse.group/u/akshika47)\
**Post date:** [April 9, 2021, 6:04pm UTC](https://sef.discourse.group/t/sending-email-notifications-from-the-schoalrx-platform/247/9 "2021-04-09T18:04:30Z")

</div>

I agree with @jaye! It is safer and extensible to handle email from the backend.

---

<div class="post-metadata">

**Author:** ![anjisvj](https://yyz2.discourse-cdn.com/free1/user_avatar/sef.discourse.group/anjisvj/32/9_2.png) [@anjisvj](https://sef.discourse.group/u/anjisvj)\
**Post date:** [April 10, 2021, 5:51am UTC](https://sef.discourse.group/t/sending-email-notifications-from-the-schoalrx-platform/247/10 "2021-04-10T05:51:58Z")

</div>

yeah, I made a mistake with that library also. We need to create an API for that as well. I have use it with NextJs which allows you to create API’s within the frontend so our only option is going with the backend.

---

<div class="post-metadata">

**Author:** ![jaye](https://yyz2.discourse-cdn.com/free1/user_avatar/sef.discourse.group/jaye/32/810_2.png) [@jaye](https://sef.discourse.group/u/jaye)\
**Post date:** [April 10, 2021, 7:14am UTC](https://sef.discourse.group/t/sending-email-notifications-from-the-schoalrx-platform/247/11 "2021-04-10T07:14:29Z")

</div>

+1 for `spring-boot-starter-mail` because it is independent of the service provider that we are going to use. Also, we could create a [Google application password](https://support.google.com/accounts/answer/185833?hl=en) from our own accounts to test the application.

@YohanAvishke @anjisvj @Gravewalker How do we plan to execute the development of this task. How long will it take to have this functionality?

These are the functional requirements:

- mentor\_selection → mentee\_application
  - Sending email notifications to the mentors with their status (approved or rejected)

- mentee\_application to mentee\_selection
  - Sending email notifications to the selected mentors with a reminder to check their mentees. (no need to display mentees on the email at this stage)

- Mentee\_selection → Mentee\_confirmation
  - Sending email notifications to the mentees who have been approved by multiple mentors with a reminder to pick their mentors (no need to display mentors at this stage)

- Mentee\_Confirmation → Ongoing
  - Sending email notifications to the mentors to check out their mentees. (sending the dashboard link would be sufficient. No need to list mentees)
  - Sending email notifications to the mentees to check out their mentor.

- These emails don’t need to be fancy HTML emails at this stage. Having a plain text email is enough at this stage. We can improve it over time. 💗
- Configuring it to work with google application password seems easier for testing. Define it as in the application.property file

These are the things that came into my mind at the moment. Please update the thread with your own suggestions.

---

<div class="post-metadata">

**Author:** ![YohanAvishke](https://yyz2.discourse-cdn.com/free1/user_avatar/sef.discourse.group/yohanavishke/32/106_2.png) [@YohanAvishke](https://sef.discourse.group/u/YohanAvishke)\
**Post date:** [April 10, 2021, 8:24am UTC](https://sef.discourse.group/t/sending-email-notifications-from-the-schoalrx-platform/247/12 "2021-04-10T08:24:33Z")

</div>

Hi @jaye here you can find more suggestions and discussions we had before on the subject

> [@Implementing the emailing function for ScholarX platform](https://sef.discourse.group/t/implementing-the-emailing-function-for-scholarx-platform/243):
>
> We need to add emailing feature for the platform. There will be different kinds of scenarios that we might be needed to send emails to. I’ll be listing the scenarios in this thread.

Idea was to finalise the feature by the end of current sprint (deadline: 2021-04-16T18:30:00Z)

---

<div class="post-metadata">

**Author:** ![jaye](https://yyz2.discourse-cdn.com/free1/user_avatar/sef.discourse.group/jaye/32/810_2.png) [@jaye](https://sef.discourse.group/u/jaye)\
**Post date:** [April 11, 2021, 4:29am UTC](https://sef.discourse.group/t/sending-email-notifications-from-the-schoalrx-platform/247/13 "2021-04-11T04:29:09Z")

</div>

Oh I completely missed that thread.

---

<div class="post-metadata">

**Author:** ![anjisvj](https://yyz2.discourse-cdn.com/free1/user_avatar/sef.discourse.group/anjisvj/32/9_2.png) [@anjisvj](https://sef.discourse.group/u/anjisvj)\
**Post date:** [April 18, 2021, 10:18am UTC](https://sef.discourse.group/t/sending-email-notifications-from-the-schoalrx-platform/247/14 "2021-04-18T10:18:51Z")

</div>

![image](https://global.discourse-cdn.com/free1/uploads/sef/original/1X/be2ff1c566886dca5f2f6a9446e0ab3a99c370d6.png)

![image](https://global.discourse-cdn.com/free1/uploads/sef/original/1X/0fac726fd987e8231c17defb6e79c4862db4347d.png)

 ![image](https://global.discourse-cdn.com/free1/uploads/sef/original/1X/a5595337ed2051c3daccfe0d9cbce71f9615b590.png)

The PR is ready for review.

> <https://github.com/sef-global/scholarx/pull/119>
>
> \## Purpose
> \- The purpose of this PR is to fix #118 #96 
> 
> \## Goals
> \- Adding the emailing function
> 
> \## Approach
> \- Added the spring boot starter mail 
> \- Created the email utility function
> \- Created the get mentees by program id endpoint
> 
> \## Checklist
> \- \[x\] This PR doesn't commit any keys, passwords, tokens, usernames, or other secrets.
> \- \[x\] I have read and understood the development best practices guidelines ( http://bit.ly/sef-best-practices )
> \- \[x\] My code follows the style guidelines of this project
> \- \[x\] I have performed a self-review of my own code
> \- \[\] I have commented my code, particularly in hard-to-understand areas
> \- \[\] I have made corresponding changes to the documentation

@YohanAvishke
