In this post, we are going to see how to send email from cloud function using a customized html template by listening to a pub/sub event .
Let’s take a scenario of notifying the completion of storage transfer service Job , So when the data transfer from AWS S3 to GCP GCS gets completed, it should send an email to the respective team notifying them about the completion of transfer.
Transfer data from AWS to GCP using Storage Transfer Service | Google Cloud Blog
A step-by-step process for transferring data from AWS S3 to Google's Cloud Storage in a secure manner using identity…
The storage transfer service job should be configured to send a message to a Pub/Sub topic and Later we have to create a cloud function subscribed to that pubsub topic.
When the transfer completion event gets posted to the pubsub topic, it will trigger the cloud function, in turn the cloud function will send the status via email to the respective teams.
There are google documentations available on how to have a cloud function subscribe to a pub/sub topic and how to send an email after a pub/sub event from cloud function.
Pub/Sub triggers | Cloud Functions Documentation | Google Cloud
In Cloud Functions, a Pub/Sub trigger enables a function to be called in response to Pub/Sub messages. When you specify…
Listen to Cloud Pub/Sub topic and send an email | Application Integration | Google Cloud
See the supported connectors for Application Integration. Learn how to create a sample integration using Application…
GitHub - GoogleCloudPlatform/cloud-pubsub-sendmail: pubsub_sendmail - Send emails from Google Cloud…
pubsub_sendmail - Send emails from Google Cloud Pub/Sub events using a Google Cloud Function - GitHub …
But if you want to send an email with a customized template specific for your organization and also wants to capture detailed information on the event trigger, you can use the below code snippet.