You need to enable JavaScript to run this app. 为什么Node.js调用Gmail API发邮件时主题Emoji无法渲染
优惠活动
大模型
产品
解决方案
定价
更多

为什么Node.js调用Gmail API发邮件时主题Emoji无法渲染

我通过Node.js服务调用Gmail API发送邮件,使用如下工具函数构造邮件原始报文:

message += '[DEFAULT EMOJI 😆]'
  
const str = [
    'Content-Type: text/html; charset="UTF-8"\n',
    'MIME-Version: 1.0\n',
    'Content-Transfer-Encoding: 7bit\n',
    'to: ',
    to,
    '\n',
    'from: ',
    from.name,
    ' <',
    from.address,
    '>',
    '\n',
    'subject: ',
    subject + '[DEFAULT EMOJI 😆]',
    '\n\n',
    message
  ].join('');

  return Buffer.alloc(str.length, str).toString('base64').replace(/\+/g, '-').replace(/\//g, '_');

我用于发送邮件的调用代码如下:

const r = await gmail.users.messages.send({
    auth,
    userId: "me",
    requestBody: {
        raw: makeEmailBody(
            thread.send_to,
            {
                address: user.from_email,
                name: user.from_name,
            },
            campaign.subject,
            campaign.template,
            thread.id
        ),
    },
});

目前邮件正文中的Emoji可以正常渲染,但主题字段的Emoji无法正常显示,实际效果如下图所示:

桌面端Google Chrome浏览器中的Gmail界面显示效果
移动端Gmail App的显示效果

左侧为桌面端Google Chrome浏览器中的Gmail界面显示效果,右侧为移动端Gmail App的显示效果。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.11.17 02:36:04