通过Google Cloud Platform从Firebase发送自动电子邮件(无第三方)

问题描述 投票:35回答:2

我们已经进行了许多小时的研究。

出现在每个地方的第一个解决方案(也有其他StackExchange问​​题)也在使用第三方服务SendGrid.com,有时与Zapier结合使用,但这不是我们要实现的方法。

对于中间没有第三方发送的情况,第一个似乎可行的解决方案是“ Firebase Triggers”,该解决方案已在Google I / O 2014上发布,但从未生效,而seemingly was merged into Google Cloud Functions仍在Alpha中。

我很确定我差不多一年前在FireBase博客上的链接中看到了该解决方案,但the only post that seems to have existed upon that matter is now empty

[我们之前从未使用过GCP,但是我们的逻辑告诉我们,应该使用另一个GCP现有API解决此问题(在Google内部),Mail API显然是正确的,但是似乎没有任何问题。我们的Firebase Web应用程序可以发出请求的方式。

[任何人(最好具有GCP经验的人,请在这里说明情况如何,以及Google如何期望它的FireBase开发人员向他们的客户发送电子邮件?

email google-app-engine firebase google-cloud-platform google-cloud-functions
2个回答
27
投票

Firebase功能

如@ajostergaard所言,今天Google已将announced等待已久的Google Cloud Functions,但正是为Firebase,他们实现了自己的特定Firebase Functions来代替Triggers shown in conferences since Nov. 2014(超过2年前!)和mentioned in Firebase groups

这是一个示例链接,准确解释了如何执行此问题中要求的操作:


0
投票

firebase还有另一种方法,nodemailer expressjs是可选的,工作代码

var express = require('express'); 
var app =  express();
var nodemailer=require('nodemailer');
const functions = require('firebase-functions');

var transporter = nodemailer.createTransport('smtps://[email protected]:[email protected]');

exports.sendMail = functions.https.onRequest((req, res) =>{
    var mailOptions={
        to: '[email protected]',
        subject: 'Test Mail',
        html: 'Testing the Mail'
    }
    transporter.sendMail(mailOptions,function(err,response){
        if(err){
            res.end('Mail not sent');
        }
        else{
            res.end('Mail sent');
        }
    });
});

只需授予您的gmail访问权限即可发送电子邮件或生成APP密码。我有可用的代码,因此现在可以实现

发现有用的链接

https://medium.com/@edigleyssonsilva/cloud-functions-for-firebase-sending-e-mail-1f2631d1022ehttps://github.com/nodemailer/nodemailer

© www.soinside.com 2019 - 2024. All rights reserved.