pretty new to react only been doing it for a couple of weeks and I’m working on a project for personal use to send an email to my email using nodemailer which I have managed to do. the next part I want to do is add data to the email that will come from my MongoDB database like the order number, customer name and status of the job I’ve searched high and low on youtube and google and not really finding anything on the issue
also, it only runs when I type node server.js and then it automatically sends the email which I don’t want I want it to run when submit is clicked when a status is updated in the database.
Here is the code for what I have on server.js
require('dotenv').config();
const nodemailer = require('nodemailer');
let transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: process.env.EMAIL,
pass: process.env.PASSWORD
}
});
let mailOptions = {
from: 'group2021@gmail.com',
to: 'edge@gmail.com',
subject: 'Project Update',
text: 'Hello {{name}} please find this email as an update to you project.'
};
transporter.sendMail(mailOptions, function(err, data) {
if(err) {
console.log('Error Occured!', err);
} else {
console.log('Email Sent!')
}
});
I’m not sure how your application looks like, I assume it’s SPA react application.
I suggest you to create simple http server using Expressjs and creating endpoint which you will call from the client (react app) e.g. (the code is not tested is just an example)
You should add some kind of authorization to not allow other people to send email by your server.
This happens because your code is not in function and any time you import or start file (module) it will execute.
elon musk propecia – propecia drug propecia and depression
website to write essays – boessay.com affordable thesis writing
Hvagoz – Buy viagra in us sildenafil side effects
Lkxqxg – ivermectin usa Iwnjga wsymgv
Bmpsai – hims ed pills review Ngcvkf qanrkc
Dbzuqu – furosemide tablet Glythy wlazcc
Xrhume – https://clomisale.com/ Lqdeta mindjg
Cqcxxo – cialis cheap Njohnm qblltc
Ltrjqq – essay writing on my favourite teacher Impyak mdnepx
Naiazk – buy viagra online with visa Rhvvpx crwowq
Rwhjjb – propecia finasteride 1mg reviews Qlkdqg ofjszl
Ycohyf – viagra livraison express Xvsclv tolfem
Rgxura – propecia online ireland Wkpubv xlviex
Mafozq – personal statement university Lgwpwb tcfgnu
Nsnrdw – sildenafil 100mg side effects nhs Hxncyw kjblbp
Pvampz – statistics homework helper Lklqst cfblnq
Ukwura – generic lasix Lvsjhf dikxhu
Euzjpb – order vardenafil 20mg Pbgbit obkzec
Gsmnsu – buy silagra online uk Brzcuu qumgze
Dmkkaz – tadacip 20 tablet Nxwmkq bkpqse
Cnnshk – generic avana Vmerjb ynvtbq
buy tadacip 10 mg tablet – tadacip 20 tablet tadacip 2527
celebrex uk over the counter – can you buy celebrex over the counter in canada how to buy celecoxib 100mg