Firebase发送电子邮件功能

时间:2017-03-31 13:45:07

标签: firebase gmail

我一直在玩firebase教程和新功能,并试图实现这个具体的例子: https://github.com/firebase/functions-samples/tree/master/quickstarts/email-users

当我触发触发器时,邮件不会被发送,我在日志控制台中收到以下错误:

Error: Invalid login: 535-5.7.8 Username and Password not accepted. Learn more at
535 5.7.8  https://support.google.com/mail/?p=BadCredentials 141sm3120746ioe.47 - gsmtp
    at SMTPConnection._formatError (/user_code/node_modules/nodemailer/lib/smtp-connection/index.js:557:19)
    at SMTPConnection._actionAUTHComplete (/user_code/node_modules/nodemailer/lib/smtp-connection/index.js:1248:34)
    at SMTPConnection._responseActions.push.str (/user_code/node_modules/nodemailer/lib/smtp-connection/index.js:340:26)
    at SMTPConnection._processResponse (/user_code/node_modules/nodemailer/lib/smtp-connection/index.js:706:20)
    at SMTPConnection._onData (/user_code/node_modules/nodemailer/lib/smtp-connection/index.js:509:14)
    at TLSSocket._socket.on.chunk (/user_code/node_modules/nodemailer/lib/smtp-connection/index.js:461:47)
    at emitOne (events.js:96:13)
    at TLSSocket.emit (events.js:188:7)
    at readableAddChunk (_stream_readable.js:176:18)
    at TLSSocket.Readable.push (_stream_readable.js:134:10)

我做错了什么?它没有说关于在电子邮件帐户上放置一些授权的问题。只是密码。应该很简单。

2 个答案:

答案 0 :(得分:5)

如果您在终端中键入:firebase functions:config:get,您将能够看到gmail和密码带有双引号。 我是这样的:

{
  "gmail": {
    "password": ""pass"",
    "email": ""user@gmail.com""
  }
}

所以我在终端输入这样的内容,它对我有用: 没有标记

firebase functions:config:set gmail.email=user@gmail.com gmail.password=pass

答案 1 :(得分:1)

不太确定您是否已按照列出的here

完成初始配置部分

For Gmail, enable these: 1. https://www.google.com/settings/security/lesssecureapps 2. https://accounts.google.com/DisplayUnlockCaptcha

如果您已完成此操作,则可以将emailpassword作为字符串传递到const gmailEmail = 'gmail.com'const gmailPassword = 'password'以检查其是否正常工作