40

We've been doing some research for many hours already.

The first solution that appears everywhere (other StackExchange questions too) is using third-party service SendGrid.com and sometimes in conjunction with Zapier, but that's not the approach we are wanting to implement.

For sending without third-parties in the middle, the first solution that seemed viable was "Firebase Triggers", which was anounced on Google I/O 2014 but never came to life and seemingly was merged into Google Cloud Functions which is still in Alpha.

I'm pretty sure I had seen the solution almost a year ago in a link on the FireBase blog, but the only post that seems to have existed upon that matter is now empty.

We've never worked before with GCP, but our logic tells us this matter should be solved (inside Google) using with another GCP existing API, and the Mail API is apparently the correct one, but there seems not to be any way our Firebase Web App could make the request.

Could anyone (preferably with GCP experience) please explain what's the situation here, and how does Google expects it's FireBase developers to send emails to their clients?

DavidTaubmann
  • 2,789
  • 2
  • 27
  • 40
  • 2
    For an up to date version of that blog post, see: https://cloud.google.com/solutions/mobile/firebase-app-engine-android-studio – Frank van Puffelen Mar 06 '17 at 02:57
  • 2
    Firebase has no built-in support for sending developer-specified email. In that sense it also has no expectation on how an app sends email to its users. One way to do so would be through app engine as shown in the blog post you mentioned. But there are many more ways to accomplish the same. – Frank van Puffelen Mar 06 '17 at 03:03
  • Thanks @FrankvanPuffelen, we are developing a WebApp, so... we would appreciate such a link for a WebApp approach if it exists... – DavidTaubmann Mar 06 '17 at 05:28
  • 1
    @davidtaubmann Actually you can follow the tutorial shared by FrankvanPuffelen by starting at "Adding backend logic using App Engine". You create a project in Android Studio but you just work in the AppEngine module part, i.e. you leave "untouched" the Android app module. – Renaud Tarnec Mar 06 '17 at 08:36
  • @frank-van-puffelen and 3371862, as I understand the link mentioned, the procedure makes an inquiry to app engine from the app itself, not from firebase, which means that in Web Apps environment, the inquiry for the email would be made by the client-browser directly to app engine... Wouldn't that be a huge security risk? And if not... Please explain why not... – DavidTaubmann Mar 09 '17 at 06:26
  • @davidtaubmann The link shows how to configure and develop a servlet in App Engine that connects to the Firebase database and installs a listener: when the listener is triggered the servlet sends a mail. The servlet is normally called through a cron job configured in the App Engine project. There is a possibility to call the servlet from a browser through the servlet URL, but this should only be used for testing. However it could indeed be called by someone else (knowing the url), and I am not sure at this moment if we can secure it, I have to dive into the doc. To be cont. – Renaud Tarnec Mar 09 '17 at 15:01
  • continued... My point with my comment above (on 6 march) was to indicate that the listener is triggered when data is added/modified to the Firebase db independently of the type of front-end which added/modified the data (an Android app, a web app or even the Firebase console). So in other words it perfectly works for your case with a WebApp. – Renaud Tarnec Mar 09 '17 at 15:01
  • @davidtaubmann Yes you can secure the cron job, see https://cloud.google.com/appengine/docs/standard/java/config/cron#securing_urls_for_cron – Renaud Tarnec Mar 09 '17 at 15:14

1 Answers1

28

Firebase Functions

As gracefully stated by @ajostergaard, TODAY Google has announced its much waited Google Cloud Functions, but precisely for Firebase they've implemented their own specific Firebase Functions which substitutes the Triggers shown in conferences since Nov. 2014 (more than 2 years ago!) and mentioned in Firebase groups .

This is an example link that explains exactly how to do what is asked in this question:

sushant-hiray
  • 1,708
  • 2
  • 19
  • 28
DavidTaubmann
  • 2,789
  • 2
  • 27
  • 40
  • 25
    My answer got deleted by a very 'nice' moderator because I apparently tried to spread the good news too eagerly. Apparently instead of answering your question I should have marked it as duplicate and pointed it to another older 'duplicate' question with lots of wrong and out of date answers on it. Sometimes I wonder! :) – ostergaard Mar 18 '17 at 18:53
  • @ajostergaard , could you please direct me to the other question you mentioned in the comment? – DavidTaubmann Mar 23 '17 at 21:00
  • 2
    There are many to which my answer was appropriate, not necessarily duplicates. Some examples: http://stackoverflow.com/questions/17723195/is-there-any-way-to-do-email-confirmation-for-firebase-user-creation-and-or-pass/42706591 http://stackoverflow.com/questions/39180768/send-email-from-android-using-firebase/42704008 http://stackoverflow.com/questions/28656191/send-email-when-match-in-firebase-database/28656376 – ostergaard Mar 25 '17 at 08:02
  • Does this also work with non-Firebase Google Cloud Functions? – starmandeluxe Feb 06 '19 at 06:34