Reputation: 371
I am working on an app with React as the base. I have created a registration page and want to send a verification code via email to the user once he registers. I have done the UI part, but have no idea on how to proceed and make it work. I have seen how emails are sent to the user upon registration in PHP, and want to implement the same in React.
Upvotes: 0
Views: 6788
Reputation: 15903
Since you are using node, you'll be able to make use of the node mailer package. This allows you to send emails easily straight from node.
Have a look at there site for all the details on how to get it setup!
Here is some psuedo code:
User.register(userDetails).then( (createdUser) => {
// Your user is created
// Now lets send them an email
var mailOptions = {
from: '"Info ?" <[email protected]>', // sender address
to: userDetails.email, // This can also contain an array of emails
subject: 'Thanks for registering with <your site name>',
// text: 'Hello world ?', // plaintext body
html: '<b>Some HTML here....</b>' // html body
};
// send mail with defined transport object
transporter.sendMail(mailOptions, function(error, info){
if(error){
return console.log(error);
}
console.log('Message sent: ' + info.response);
});
})
Upvotes: 3