How to receive and parse email with Cloud Functions?

限于喜欢 提交于 2019-12-05 21:26:50

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

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!