I have an application, built using React. If I want to send an email to a user after another user successfully completes an action, what are some technologies I need to or can use? To clarify, I have no backend server set up yet.
-
React is frontend, emails are sent from a backend server. So React has nothing to do with this. It will greatly depend on the technology stack of your backend server.Alex Wayne– Alex Wayne2020-02-08 06:35:39 +00:00Commented Feb 8, 2020 at 6:35
-
1see stackoverflow.com/questions/55795125/…Hamid Shoja– Hamid Shoja2020-02-08 06:43:25 +00:00Commented Feb 8, 2020 at 6:43
-
@AlexWayne I was hoping for answers containing technologies to use, not technologies I don't need to use.Josh Kardos– Josh Kardos2020-02-08 17:19:08 +00:00Commented Feb 8, 2020 at 17:19
Add a comment
|
3 Answers
Check sendgrid! You can do in your backend(nodejs in this case):
const SGmail = require ('@sendgrid/mail')
SGmail.setApiKey(process.env.REACT_APP_SG_API)
app.post('/your/endpoint', (req,res) => {
const data = req.body
const mailOptions = {
from: data.email,
to:'[email protected]',
subject:'Subject',
html:`<p>${data.name}</p>
<p>${data.email}</p>
<p>${data.message}</p>`
}
SGmail.send(mailOptions).then((err,res)=>{res.redirect('/')})
})
Comments
If you're not expected to do the actual email sending, you could, in JS, build an .eml file and have the user "download" it. They would then send it in their client of choice.
Otherwise you will need, at the very least, access to a mail server, to send this multipart-mime to, or, a little safer, build the message on the server and send it internally.
1 Comment
Josh Kardos
thanks! this is a cool and different way to do it than the other answers!