用户未收到从 Firebase Cloud Function 发送的验证电子邮件

问题描述 投票:0回答:1

我遇到了负责向用户发送电子邮件验证的 Firebase 云功能的问题。该函数似乎执行成功,并且日志表明验证电子邮件已发送。然而,用户报告说他们没有收到电子邮件。enter image description here

Firebase 云功能代码:

exports.sendEmailVerification = functions.https.onCall(
    async (data, context) => {
      try {
        const user = context.auth;

        if (!user) {
          throw new functions.https.HttpsError(
              "invalid-argument", "User not authenticated");
        }

        const uid = user.uid;

        // Trigger the email verification process
        await admin.auth().updateUser(uid, {
          emailVerified: false,
        });

        console.log("Verification email sent to:", uid);
        return {success: true};
      } catch (error) {
        console.error("Error sending verification email:", error);
        throw new functions.https.HttpsError(
            "internal", "Error sending verification email");
      }
    });

采取的故障排除步骤:

  • 检查收件人的电子邮件地址是否正确。
  • 已验证收件人的电子邮件地址有效并且能够接收电子邮件。
  • 检查了 Firebase 项目配置中的电子邮件验证设置。
  • 检查了 Firebase 项目配额以确保不超出配额。
  • 查看 Cloud Function 日志,了解与电子邮件发送相关的任何错误或警告。

附加信息:

  • 云功能日志没有显示任何与电子邮件发送相关的错误。
  • 对于不同的用户和电子邮件地址,该问题始终会发生。

为了解决此问题,我是否可能缺少其他步骤或配置设置?任何有关如何进一步诊断和解决此问题的见解或建议将不胜感激。

firebase firebase-authentication google-cloud-functions email-verification
1个回答
0
投票

找到解决方案,问题是代码依赖于admin SDK中不存在的云函数(sendEmailVerification)。我删除了 Cloud Function,并直接使用 Firebase 身份验证和 SDK 处理电子邮件验证。

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