You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

部署至Vercel后SendGrid无法发送邮件问题求助

Vercel部署后SendGrid无法正常工作,Promise挂起无错误返回

我最近在一个小型项目中尝试用Vercel部署,结果遇到SendGrid无法正常工作的问题。之前在Heroku上的Node.js/Express项目里集成SendGrid从来没出过问题,但到了Vercel环境就失效了。更头疼的是SendGrid完全不返回错误信息,导致排查特别困难,Promise一直处于挂起状态。本地测试一切正常,而且已经确认环境变量配置正确且成功加载。

以下是我的代码:

const sgMail = require('@sendgrid/mail');
const { magicLinkTemplate } = require('./templates');

const sendEmail = async (msg) => {
    sgMail.setApiKey(process.env.SENDGRID_API_KEY);

    try {
        await sgMail.send(msg)
    } catch (error) {
        console.error(error);

        if (error.response) {
        console.error(error.response.body)
        }
    }
}

我已经尝试了多种修改,但都没成功。有没有人遇到过Vercel和SendGrid搭配使用的类似问题?

内容的提问来源于stack exchange,提问作者Kyle Pendergast

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.19 07:20:37