触发电子邮件Google Firestore扩展

时间:2020-10-05 21:28:40

标签: angular firebase google-cloud-firestore smtp handlebars.js

我有一个与Firebase一起使用的角度应用程序。我已经设置了一个联系表格,供人们与我联系-我将通过Firestore以电子邮件的形式接收这些消息。我正在使用触发电子邮件扩展程序。我正在接收电子邮件,但是,我没有从输入字段中获取所有信息。

  onSubmit() {
    console.log('Your form data : ', this.contactForm.value );
    const {contactFormName, contactFormEmail, contactFormSubject, contactFormMessage} = this.contactForm.value;

    this.af.collection('mail').add({
      to: '#####@gmail.com',
      message :{
  //    name: this.contactForm.value.contactFormName,
  //    email: this.contactForm.value.contactFormEmail,
      subject: this.contactForm.value.contactFormSubject,
      text: this.contactForm.value.contactFormMessage
    }

  })
  .then(res => {
      console.log(res);
      this.contactForm.reset();
  })
  .catch(e => {
      console.log(e);
  })
}}

Firestore默认只允许包含消息,HTML和文本之类的字段。我想自定义电子邮件,以使名称和电子邮件也显示在电子邮件正文中,但事实并非如此。 Firestore建议使用把手来执行此操作,但是我不清楚如何执行。这是参考链接:

https://firebase.google.com/products/extensions/firestore-send-email

1 个答案:

答案 0 :(得分:0)

如果我对您的理解正确,则想了解如何使用把手来自定义使用触发电子邮件扩展名创建的电子邮件正文。

您可以使用类似于以下内容的语句:

app.engine('handlebars', exphbs({defaultLayout: 'main'}));
app.set('view engine', 'handlebars');

,然后选择适合电子邮件上下文的布局。您可以在functions-samples/template-handlebars/functions/index.js页上查看整个示例。

有关实际布局示例,请检查A Step By Step Guide To Using Handlebars With Your Node js App