首页 > 解决方案 > 触发电子邮件谷歌 Firestore 扩展

问题描述

我有一个与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

标签: angularfirebasegoogle-cloud-firestoresmtphandlebars.js

解决方案


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

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

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


推荐阅读