Categories
Capstone Project Tech Knowledge

How to use Nodemailer

One of my tasks for the project I am working on was to create a function that allows users to send an invitation link to their candidates. So, for this functionality, I had to implement “send email” on our web application. In order to achieve the task, I had researched. I found there are two packages: nodemailer and emailjs. Long story short, I decided to use nodemalier because it is free and there is no limit on sending emails (but emailjs, you have to pay to use it or if you are willing to use the free version, it is limited to 200 emails per month).

What is the nodemailer?

Nodemailer

Nodemailer is a module for Node.js applications to allow sending email.

How to implement sending email function with nodemailer?

You might be able to find many video lectures online, but most videos are dealing the function when if it is in the same server(or Port). However, if you working on react, as you already know, the front-end and back-end are running on the different server ports. In my case, the front-end is running on port:3000 and the server is running on port:7000.


So I have to pass JSON data from 3000 to 7000. So, without middleware, you cannot achieve that.


In this case, Axios can be a good solution since you can send the data to the server port with Axios. And, here is the code I implemented:
Write Axios code on your front-end function where you want to evoke sending email

 axios({                               //call axios   method: "POST",
   //set url with your server port
   url:"http://localhost:7000/send",              
   data: {                            //build a data form
    name: emailSubject,               //Send send           
    email: emailAddress,
    messageHtml: emailContext
   }
 }).then((response)=>{                    // Waiting response  
    if (response.data.msg === 'success'){    //display result     
        alert("Email sent, awesome!");            
    }else if(response.data.msg === 'fail'){
        alert(`Oops, something went wrong with`)
    }
})

Server side code:

const express = require('express');         //load packages
const nodemailer = require('nodemailer');

app.use(express.json());

app.post('/send', (req, res)=>{            //catch post send
    console.log(req.body)

    const transporter = nodemailer.createTransport({
        service: 'gmail',
        auth:{
            user: "from email address",
            pass: "password"
        }
    })

    const mailOptions = {
                 //build mail option
        from: "quizbanana467@gmail.com",
        to: req.body.email,       //use data from front-end
        subject: `${req.body.name}`,
        text: req.body.message

    }

    
    //send email
    transporter.sendMail(mailOptions, (error, info) =>{
         //send feedback to front-end        
         if(error){
            console.log(error);
            res.json({msg: 'fail'});     
        }else{
            console.log("good")
            res.json({msg: 'success'});

        }
    })
})

Based on the email service you are using, there would be some limitations so please refer to the official nodemailer site.

//references

mailtrap.io/blog/react-send-mail

Categories
Capstone Project

Project follow up!

As I posted before, I am working on a project for cs467 class at OSU. I t has been a few weeks since my team started. I would like to talk about project status so far including blockers.

What is project about?

Briefly saying, we are creating a web based quiz creating software that allows a user create quiz and send it to candidates, such that can replace survey monkey.

What tech has been used?

We implemented our project with MERN stack ( MongoDB, Express, React, Node Js). For the framework, we are using react-bootstrap. And, we are using Auth and Redux.

What have I done so far ?

Thanks to our teammates, I mostly focus on Front-end of the program like getting data from users and display back to users. At this stage, most to data (limited to page I created) are stored in front-end as an array. This is because, that specific page should not only be able to receive a data from user, but also be able allow user the data in real time. Once, users satisfy with their entry, then data will be save on to server.

Thanks to the our teammates, back-end server is already set. Only left thing is to hook the page with the server.

Beside those technical thing, I also created a brand logo (Check out here)

logo_small.png

What have our teammates done?

They are doing incredible. Before start the project, we separated our task. Myself focus on front-end, one is focus on back-end and another member is like multiplayer since she is working on both sides.

They already set up server and link it with our SW. Most of simple pages were done already, and we are working on major part of our tool such as rendering quiz for candidates, sending invitation for quiz and so on. You will be heard something more about it later (stay tune)

Any blockers?

Working on React is a blocker itself, that is because our experience is limited. And, there are bunch of new packages and some of implementations are changed through the version update. But, our team is handling well those blockers so far by helping and sharing their knowledges.

It takes more time to complete each task than expected, but it seems worth when I see results after those hard working. Can’t wait to see our final result after this quarter.

Categories
Capstone Project Tech Knowledge

Software mockup tools

As our first task, I and other teammates created a web-application mockup that shows the general workflow and design. Wireframes are often considered an important task of the software development process since it provides a visual understanding and workflow. So, many developers never overlook the task and get help from mock-up tools such as Balsamiq and Figma.
Today, I would like to talk about the three most popular prototype mockup tools which are Balsamiq, NinjaMock, and Figma. I prefer Figma and you will find the reason later in this post.

  1. Balsmiq

I came to know the tool when I took CS361 class at Oregon State University because one of the tasks was creating a wireframe for a project. This tool was pretty powerful even it was free. You can create elements as much you want from various options(I believe there were limits for the free version, but I couldn’t find any disadvantages from the free version). And, you were able to link an element with a page so that you can create interaction between two or more elements. But, this time, we didn’t use Balsamiq this time. The reason because it is not free anymore, it gives you 30 days trial, but after the free trial, you can’t go back work on your work unless you sign up.

2. Figma

I often use Figma for personal projects. You can create prototypes for different platforms (Web, Phone, etc). You can also use it for free, but you can create only three projects with your free account. However, if you delete one of your works, then you can create another project. It means you can use the tool for free forever if you keep the number of projects.

or you can import preset from a library). However, once you are getting used to using Figma, it can be the most powerful tool to build your prototype. and even it looks so real. On the other hand, the other two tools provide a limited number of elements design and given elements looks cartoon-ish.

3. NinjaMock

I didn’t know about this mockup tool until this class. We were planning to work on Balsamiq, but we noticed Balsamiq is not free anymore so that we were looking for other tools including Figma. Our team didn’t want to spend extra time to learn figma, and didn’t want to spend money on Balsamiq. So, we came to this free version of NinjaMock. After created mock with this tool, I do not recommend to use NinjaMock unless your project is personal and small. Here are the couple of reasons. First, free version gives you very limited element capacity which is 200. It takes average of 25 elements to have a simple web page (it took 15 elements for the image below), it means you can make about 8 pages which is very small.

For free users, Figma is the best option since it has limit of projects you can create, but other sources are free. This is why I prefer Figma. Lastly, the contents above are very personal, you can find other tools better than I thought. And, every project has a different purpose so you can choose any tool that has the best fit for your project.

Categories
Capstone Project

Project Start-off

I had a 1-hour meeting with my team for the CS467 class. In this meeting, we had discussed the TEAM STANDARD which is about the team’s working rules and expectations has the goal of increasing team performance. Today, I would like to share some of our standards here.

1. Team Name

We have decided our team name as QuizBanana because one of the project requirements said that our application should be able to replace Survey Monkey. So one of our team members suggested this name.

2. Communication

Communication is very important when we are working as a team. There are many communication tools such as Discord, Slack, and Google hangout. Team QuizBanana agrees on using MS Teams because MS Teams is the official tool for the CS467 class.

3. Project Management Tool

Since it is a project class, we will work on project programming from scratch for the entire term. So, we have to take care of time. In order to manage this project, we are going to use the Jira. At first, we planned to use Asana, but Jira is one of the popular tools in the industry and it is free. So we change to Jira

4. Code Management

As everyone can expect, we are going to use Github for code management. It is free and powerful.

5. Conflict Management

I personally believe conflict management is really important especially working as a team. So, our team came up with two ways of handling this situation.

If the conflict is a team matter, be aware of any conflict that occurs with assignments or other group members. Takes steps to decide on how serious the conflict is and how it would affect other members of the team. If the conflict is an individual matter, please speak with the team member directly on the issue and allow discussion from both individuals

I am already excited about this project. All members respect each other and I can see we are trying hard to make things right.