Send email when Firestore data added

Viewed 19

I've been stuck on what should be a simple implementation. I'm using Angular.

I currently have form data being added to a Firestore, collection name is 'forms'.

I'm using the Trigger Email extension (firebase/firestore-send-email@0.1.19) and SendGrid. (My SMTP configuration is OK, as i'm receiving emails but they are blank in subject/content)

Here is my email code:

admin.firestore().collection('forms').add({
    to: to,
    message: {
        subject: subject,
        text: message,
      }
  }).then(() => console.log('Queued email for delivery!'));

this is my form code: (and the variable's im referencing in the above code)

this.myForm = this.firestore.collection('forms')
     
    this.contactForm = this.formBuilder.group({
      firstName:[null, Validators.required],
      lastName:[null, Validators.required],
      phone:[null, Validators.required],
      email:[null,[Validators.required, Validators.email]],
      message:[null, Validators.required],
      subject: 'new form recieved',
      to: 'redacted-email',
    })

i'm still quite new to firebase and firestore, so any pointers would be appreciated. i know it's not good practice to have the 'redacted email' in the form data, but i'm testing with it.

0 Answers
Related