Sending email

863 views
Skip to first unread message

Art Freeman

unread,
Dec 5, 2016, 3:40:34 PM12/5/16
to Firebase Google Group
How do I send email / group email to my user(s) in Firebase?  I don't mean auth emails, but just sending, for instance, a notification email to a registered user(s).

Willem van den Ende

unread,
Dec 7, 2016, 1:34:58 PM12/7/16
to Firebase Google Group
I've been wondering the same thing. I'm afraid one needs to set up a separate server (e.g. with firebase queue and nodemailer) to do that. Makes it a lot less Backend As a Service unfortunately.

Art Freeman

unread,
Dec 13, 2016, 5:56:49 PM12/13/16
to Firebase Google Group
Thanks, Willem, for your reply.  And, yes, I agree, that they fell short in the 'Backend As a Service' with this omission.  I hope they take note!
In the mean time, I'll have to build out the capability myself.  However, I'm not familiar with either 'firebase que' or 'nodemailer'.  When you say 'one needs to set up a separate server' - how to do this in the context of firebase?  (I'm a front end developer primarily and not savvy to all this).  So, any guidance you can offer here on how to set this all up would be much appreciated.

Gabriel Kwiecinski Antunes

unread,
Dec 13, 2016, 8:05:46 PM12/13/16
to Firebase Google Group
Firebase-queue allows you to trigger worker functions in the server by pushing task objects from your client to the real time database.

Art Freeman

unread,
Dec 14, 2016, 11:10:28 AM12/14/16
to Firebase Google Group
Wow.  I'll have to give this a thorough study.  Thank you for the links.


On Monday, December 5, 2016 at 12:40:34 PM UTC-8, Art Freeman wrote:

Art Freeman

unread,
Dec 30, 2016, 10:53:12 AM12/30/16
to Firebase Google Group
Willem - you recommended firebase queue with nodemailer.  How does one install nodemailer on the firebase server?  (installing it locally has no effect).  Thanks.


On Monday, December 5, 2016 at 12:40:34 PM UTC-8, Art Freeman wrote:

Willem van den Ende

unread,
Jan 4, 2017, 10:28:34 AM1/4/17
to fireba...@googlegroups.com
Art, you need your own server for that (could also be AWS or something like that) - the 'serverless' of firebase unfortunately goes out the window once you want to send e-mail.

--
You received this message because you are subscribed to a topic in the Google Groups "Firebase Google Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/firebase-talk/Xsm1dJNSCJc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to firebase-talk+unsubscribe@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/f121e073-6431-41b1-93c1-b228806cbb92%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Next conference: Agile Cambridge 28-30 September, Cambridge UK.

Living Software ltd
www.livingsoftware.co.uk - @mostalive
uk mobile: +447438651672
dutch mobile: +31684255792
skype: willemvandenende

DarkToLight

unread,
Feb 3, 2017, 10:31:28 AM2/3/17
to Firebase Google Group
In the same boat here, unfortunately (being a total backend noob, that is). Just to make sure I am not going the wrong path: For sending an email from my contact form with nodemailer I need to serve my web-app with express, meaning no Firebase hosting. Is that right?
Al


Am Mittwoch, 4. Januar 2017 16:28:34 UTC+1 schrieb Willem van den Ende:
Art, you need your own server for that (could also be AWS or something like that) - the 'serverless' of firebase unfortunately goes out the window once you want to send e-mail.
On Fri, Dec 30, 2016 at 3:00 PM, Art Freeman <a...@lotusmultimedia.com> wrote:
Willem - you recommended firebase queue with nodemailer.  How does one install nodemailer on the firebase server?  (installing it locally has no effect).  Thanks.

On Monday, December 5, 2016 at 12:40:34 PM UTC-8, Art Freeman wrote:
How do I send email / group email to my user(s) in Firebase?  I don't mean auth emails, but just sending, for instance, a notification email to a registered user(s).

--
You received this message because you are subscribed to a topic in the Google Groups "Firebase Google Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/firebase-talk/Xsm1dJNSCJc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to firebase-tal...@googlegroups.com.

To post to this group, send email to fireba...@googlegroups.com.

Alan deLespinasse

unread,
Feb 4, 2017, 11:40:22 AM2/4/17
to Firebase Google Group
You need some kind of server to send your emails, and there's no way to run such a server on Firebase Hosting. You can, however, still serve your web page from Firebase Hosting if you want; there's no reason that has to be served from the same place as your email server.

Also, please don't set it up in a way that would effectively be an open relay. Maybe this is obvious to everyone, but I haven't seen it mentioned in this thread, so I thought I'd mention it. It would be very easy to accidentally give people an easy way to send spam.

DarkToLight

unread,
Feb 4, 2017, 8:32:47 PM2/4/17
to Firebase Google Group
So I'd just define my POST request route with Express and set up the nodemailer transporter on tthe server side, and go on and let Firebase Hosting do its thing to serve the routes for all GET requests? That would be great, I wouldn't want to miss Firebase Hosting, it's just super fast and easy. Thank you!

Alan deLespinasse

unread,
Feb 6, 2017, 5:51:11 PM2/6/17
to Firebase Google Group
Yes, it works pretty well that way; I've done it. (Except I used Mailgun and their native API instead of nodemailer.)

You can also optionally use firebase-queue to trigger the server to send an email. The advantages of this are that your client-side code doesn't need to know the address of your server, you don't need to worry about authenticating users (you can use a Firebase database write rule to make sure the user is authorized), and you get automatic retries on failure (on the client side, it's just fire-and-forget). The disadvantages are that you need to have a server process running all the time for firebase-queue to work, and firebase-queue is a Node.js library, so you can't write it in some other language if you want.

It seems like it would probably be nice to have a GitHub repo with an example of how to set this up. Does something like that exist? I'd make one if I had any time. Maybe some weekend.

DarkToLight

unread,
Feb 7, 2017, 10:07:57 AM2/7/17
to Firebase Google Group
This is giving me hope I can do it, thank you! I wanted to use Mailgun as well, but with nodemailer-mailgun-transport, like so: 
 
app.post('/contact', function (req, res) {
    var name = req.body.name;
    var email = req.body.email;
    var message = req.body.message;
    var errorField = req.body.errorField;
    var isError = false;

    if (errorField) {
        isError = true;
    }
    console.log('\ntransmitted data: ' + name + ' ' + email + ' ' + message + '\n');

// create transporter to send email using default SMTP transport: 
    const transporter = nodemailer.createTransport(mailgun(auth));

// setup email data
    const data = { 
        from: '"MyBranding" <no-r...@my-domain.domain>',
        to: 'm...@email.address',
        'h:Reply-To': email,
        subject: '📧 Inquiry from ' + name,
        text: message + '\n\nPlease reply to: ' + email,
        err: isError
    };

// send mail with defined transport object
    transporter.sendMail(data, (err, info) => {
        if(err) {
            console.log(err);   
        }
        else {
            console.log('Message sent.');
        }
    });
});

with auth being an object with my Mailgun api_key and domain address.

But using firebase-queue to send an email sounds very interesting, too. Until now, I'm just storing messages from my contact form in the database anyway, so this seems like the next step to do it right. And I wanted to dive into firebase-queue anyway... 

A GitHub example would be really nice, of course! Didn't find one out there in the wild yet, but maybe somebody else knows??

DarkToLight

unread,
Feb 13, 2017, 12:28:52 AM2/13/17
to Firebase Google Group
Just one final thing, I came across the custom email action handler section in the Firebase docs, thinking that actually everything is already kind of baked in with the auth.sendPasswordResetEmail(restoredEmail) function - we are just not allowed to use it for different use cases than password reset (yet), which is a little sad. So maybe we just need to ask Firebase for rethinking policies a little? 

For my contact form problem it would be enough to just send out a very simple notice saying "You have a new message" to the domain owners, with a link to direct them to a login page for their email contents that I stored in the Firebase database.

Maybe this use case is even already in the making? Wouldn't be too surprised.


Am Montag, 6. Februar 2017 23:51:11 UTC+1 schrieb Alan deLespinasse:
Reply all
Reply to author
Forward
0 new messages