I want to send a thank you email after user sign up but i don't know how to pass username to my email template. I have the following code:
app.mailer.send('email', {
to: '[email protected]', // REQUIRED. This can be a comma delimited string just like a normal email to field.
subject: 'Test Email', // REQUIRED.
user: req.body.user, // All additional properties are also passed to the template as local variables.
}, function (err) {
if (err) {
// handle error
console.log(err);
res.send('There was an error sending the email');
return;
}
res.send('Email Sent');
});
email template:
<html>
<head>
<title>{{subject}}</title>
</head>
<body>
Thank you {{user}}
</body>
</html>
You can pass properties to the request.
{
to: '[email protected]', // REQUIRED. This can be a comma delimited string just like a normal email to field.
subject: 'Test Email', // REQUIRED.
username: req.body.username,
myVar: 'username'
}
The variable myVar
is passed as local variable to the template
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With