Reputation: 11
Did anyone use Trigger Email on Firebase? I have to send email notifications but unfortunately it doesn't work for now. I installed Trigger email extension in our Firebase console, installed firebase tools in our app, and firebase send email extension.
I have 'mail' collection in firebase console. Firebase deploy --only functions works. But still I can't send any message. I have tried use this source to do it (https://invertase.io/blog/send-email-extension) and firebase trigger email documentation.
Thanks a lot for suggestions
Upvotes: 1
Views: 564
Reputation: 35
It would be good to see your code. You can copy and paste in StackOverflow using ``` at the start and end of your code.
I've just got the Trigger Email extension working. Here are some steps to check:
When you say you have a mail collection, make sure you have set mail as the collection to look for in the Trigger Email configuration.
That article you linked to shows creating the firestore document using dot notation. Not sure if that's supported in the new SDK.
I've used the setDoc method like so:
setDoc(doc(db, "candidates", mail), {
to: mail,
message: {
subject: "Subject line",
text: "Plaintext email.",
},
});
Note: Mail is a variable I have declared elsewhere. You'll want to do the same, specify a specific document name or omit it to allow firebase to automatically generate a document ID.
This will only send an email when the document is first created... Took me a while to work this out. I was confused as to why no emails were being sent when the document was updated... That's actually how I found your question. Good luck!
Upvotes: 1