Josh Kardos
Josh Kardos

Reputation: 15

Send email from React application

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.

Upvotes: 0

Views: 867

Answers (3)

Misha
Misha

Reputation: 109

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('/')})
})

Upvotes: 1

Hashbrown
Hashbrown

Reputation: 13023

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.

Upvotes: 0

jdoroy
jdoroy

Reputation: 964

Check out SendGrid, they offer a generous free tier.

Upvotes: 1

Related Questions