When the button is pressed, execute an ajax POST request to your express server, i.e. "/ contactus". / contactus can receive email, subject and content from mail data and send a function to mail.
In reagent:
$.ajax({
url: '/contactus',
dataType: 'json',
cache: false,
success: function(data) {
}.bind(this),
error: function(xhr, status, err) {
console.error(status, err.toString());
}.bind(this)
});
In express, add the nodemailer code to the express mail handler:
app.post('/contactus', function (req, res) {
});
source
share