【问题标题】:SMTP Firebase ApplicationSMTP Firebase 应用程序
【发布时间】:2018-03-11 22:41:52
【问题描述】:

因此,我一直在查看 StackOverflow 上的几个问题的答案、阅读博客、观看教程......而且我没有运气尝试使用 Gmail 使用 Firebase Cloud Functions 通过 SMTP 发送电子邮件作为响应到 HTTP 请求。我已经注册了付款并尝试使用 Mailgun 等第三方,但我也遇到了问题。这是我在使用 Gmail SMTP 时遇到的错误。

{ Error: connect ETIMEDOUT 173.194.74.17:465
at Object.exports._errnoException (util.js:1020:11)
at exports._exceptionWithHostPort (util.js:1043:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1090:14)
code: 'ECONNECTION',
  errno: 'ETIMEDOUT',
  syscall: 'connect',
  address: '173.194.74.17',
  port: 465,
  command: 'CONN' }

这是我目前使用的代码:

var transporter = nodemailer.createTransport('smtps://email@gmail.com:password')

function sendTestEmail(user) {
  ref.child('users').child(user).once('value').then(snap => {
    console.log(snap.val()["Email"])// will be 'email' when looking at angels and not users
    const mailOptions = {
      from: '"The Angel App" <email@gmail.com>',
      bcc: snap.val()['Email'],
      subject: "This is a test for missed checkins",
      text: "Testing the cloud functions"
    }
    return transporter.sendMail(mailOptions).then(() => {
      console.log("email sent to ", user)
      return "email sent"
    }).catch(error => {
      console.log(error)
    })
  }).catch(error => {
    console.log(error)
  })

我也做了:

// const transporter = nodemailer.createTransport({
//   host: 'smtp.gmail.com', 
//   port: 465,
//   secure: true,
//   auth: {
//     user: 'email@gmail.com',
//     pass: 'password'
//   }
// })

起初,我收到一封来自 Gmail 的反欺诈电子邮件,说某个应用正在尝试登录并编辑我的设置(如果是我)。所以我做了。任何见解都会很棒。

【问题讨论】:

    标签: javascript firebase smtp google-cloud-functions


    【解决方案1】:

    所以我决定尝试一些不同的东西,并通过 zoho 创建了一封商务电子邮件,并且成功了。我做了运输车:

    const transporter = nodemailer.createTransport({
      host: 'smtp.zoho.com', 
      port: 465,
      secure: true,
      auth: {
        user: 'noreply@jacobzivandesign.com',
        pass: 'password'
      }
    })
    

    我必须在 sendTestEmail 函数中进行的重要更改是在 From 行中

    function sendTestEmail(user) {
      ref.child('users').child(user).once('value').then(snap => {
        console.log(snap.val()["Email"])// will be 'email' when looking at angels and not users
        const mailOptions = {
          from: '"The Angel App" <noreply@jacobzivandesign.com>',
          bcc: snap.val()['Email'],
          subject: "This is a test for missed checkins",
          text: "Testing the cloud functions"
        }
        return transporter.sendMail(mailOptions).then(() => {
          console.log("email sent to ", user)
          return "email sent"
        }).catch(error => {
          console.log(error)
        })
      }).catch(error => {
        console.log(error)
      })
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-05-10
      • 1970-01-01
      • 2019-10-26
      • 2019-05-22
      • 2014-03-02
      • 2011-07-08
      • 2018-01-20
      • 2018-05-07
      相关资源
      最近更新 更多