How to receive and parse email with Cloud Functions?

前端 未结 2 930
名媛妹妹
名媛妹妹 2021-01-02 22:34

Google Cloud Functions allows you to easily activate a function upon a trigger (eg Firebase data change, HTTP request...).

I am looking for a way to execute a functi

相关标签:
2条回答
  • 2021-01-02 23:19

    Google Cloud Functions does not provide a permanent listener on an endpoint. There is also no event source for SMTP, which is the protocols involved with email delivery. So you can't simple respond to emails as they come in with Cloud Functions at the moment.

    What you can do is direct the traffic to an existing SMTP server, and then use Cloud Functions to read from there at an interval.

    An alternative is to use the Sendgrid Inbound Email API, which can call a webhook for every message it receives. And your webhook would then be a HTTP triggered Cloud Function.

    0 讨论(0)
  • 2021-01-02 23:32

    One option if you use GSuite is to use the Gmail watch mechanism to listen to new emails in your inbox. The message can then be posted to a PubSub topic which can trigger a Cloud Function to parse the email and perform your necessary next steps.

    Here is a good use case that explains this mechanism
    https://cloud.google.com/blog/products/application-development/adding-custom-intelligence-to-gmail-with-serverless-on-gcp

    0 讨论(0)
提交回复
热议问题