I'm using the firebase trigger email extension to send mail to the site manager. In the inbox, I'm getting the mail but the same from-address as to-address but I need to give the user's mail address as from-address.
const email = req.body.email;
const name = req.body.name;
const text = req.body.text;
const subject = req.body.subject;
admin
.firestore()
.collection("mail")
.add({
from:email,
to: "sitemanager@gmail.com",
message: {
subject: subject,
html: "This is the <code>HTML</code> section of the email body.",
},
})
While configuring the extension is asking for default from email address.what should I give there
Seems to me you can go with the the instructions that you're showing in your question, and use an email address "specified in the added email document". The email address you enter in the box is just the default address in case there is no address in the document.
From the documentation:
Adding a document triggers this extension to send an email built from the document's fields. The document's top-level fields specify the email sender and recipients, including to, cc, and bcc options (each supporting UIDs).
Unfortunately, the documentation doesn't tell you the exact name of the field to use in the newly created document, but the source code suggests it's the "from" field.
So, if you want to dynamically specify a sender email address, write it to the field called "from" in the document. It looks like you're already doing that. If you don't write one, the extension will simply use the email address that you type into the configuration.