DanielAttard
DanielAttard

Reputation: 3615

Use Cloud Pub/Sub to trigger sending of email

I'm trying to figure out how to use Cloud Pub/Sub to trigger the sending of an email when a file is added to a storage bucket.

Currently using PHP72 in Google App Engine standard environment. First I created a Topic that creates a message when a file is added to the storage bucket. Then I created a Pull subscription which reads the message. I can view the messages in the GCP console, but what I would like to happen is that I want to be notified by email, preferably with a copy of the file added to the email as an attachment. Is this possible? I tried looking for a solution or tutorial but came up empty.

Upvotes: 0

Views: 5909

Answers (2)

marian.vladoi
marian.vladoi

Reputation: 8074

You can implement the send mail login in a cloud function which will be triggered by Pub/Sub (Node.js,Python,Go).

Using Pub/Sub to trigger a Cloud Function

Upvotes: 2

Alex Hong
Alex Hong

Reputation: 346

Instead of using a pull subscription, you should probably use a push subscription with App Engine, combined with one of the third party mail services such as Send Grid or MailJet.

The upload of an object to GCS triggers a message to be sent to the topic, and the push subscription delivers that message to App Engine.

Unfortunately, there aren't any full tutorials asking for exactly what you want, but hopefully this helps. Feel free to request a community tutorial for this by filing an issue on the GCP community toturial repo.

Upvotes: 1

Related Questions