I want to send an email to users with nodemailer. I have an html template but I cannot use it. Template html file is under functions folder (same folder with index.js) What should I write in html section for nodemailer?
const mailOptions = {
from: `blabla@blabla.com`,
to: snap.data().email,
subject: 'blablabla welcome',
html: '', // ???
};
As stated in the message configuration:
The following are the possible fields of an email message:
- from - The email address of the sender. All email addresses can be plain ‘sender@server.com’ or formatted '“Sender Name” sender@server.com', see Address object for details
- to - Comma separated list or an array of recipients email addresses that will appear on the To: field
- subject - The subject of the email.
- text - The plaintext version of the message as an Unicode string, Buffer, Stream or an attachment-like object ({path: ‘/var/data/…'})
- html - The HTML version of the message as an Unicode string, Buffer, Stream or an attachment-like object ({path: ‘http://…'})
var message = {
from: "sender@server.com",
to: "receiver@sender.com",
subject: "Message title",
text: "Plaintext version of the message",
html: "<p>HTML version of the message</p>"
};
In short, those are the most common values used to send an email message. The html field is used to put the body of the message using HTML to format it. If you only want to send it in plaintext (without formatting) or to provide fallback support to devices with plaintext support only, you can use the text field alongside or instead of html field.