What does "Not authorized to send emails" mean in the context of Resend?

huangapple go评论76阅读模式
英文:

What does "Not authorized to send emails" mean in the context of Resend?

问题

我的公司使用Resend,我有一把由公司颁发的Resend API密钥。

我试图从同一个账户向我的公司电子邮件账户发送一封测试邮件。

我的Node.js代码:

import { Resend } from 'resend'
const resend = new Resend("api-key")

const sendTestEmail = async () => {
    try {
        await resend.emails.send({
            from: 'Test <my.email@companydomain>',
            to: ['my.email@companydomain'],
            subject: 'Test',
            text: 'Hello World!'
        })
    } catch (e) {
        console.log(e)
    }
}

sendTestEmail()

当我运行上面的代码时,我收到以下异常:

{
  name: 'validation_error',
  message: 'Not authorized to send emails from <companydomain>',
  statusCode: 401
}

不清楚是什么"未授权"。据我所知,可能是以下任何一种:

  • 我的API密钥未获授权。
  • 我工作的机器未获授权。
  • JS API未获授权。
  • 公司的Resend账户未获授权。

如果有人熟悉Resend,我将非常感激您的帮助。

英文:

My company uses Resend and I have a Resend API key issued by my company.

I'm trying to send a test email to my company email account from the same account.

my Node.js code:

import { Resend } from &#39;resend&#39;
const resend = new Resend(&quot;api-key&quot;)

const sendTestEmail = async () =&gt; {
    try {
        await resend.emails.send({
            from: &#39;Test &lt;my.email@companydomain&gt;&#39;,
            to: [&#39;my.email@companydomain&#39;],
            subject: &#39;Test&#39;,
            text: &#39;Hello World!&#39;
        })
    } catch (e) {
        console.log(e)
    }
}

sendTestEmail()

When I run the code above, I get the following exception:

{
  name: &#39;validation_error&#39;,
  message: &#39;Not authorized to send emails from &lt;companydomain&gt;&#39;,
  statusCode: 401
}

It's unclear what thing is "not authorized". As far as I'm aware, it could be any of the following:

  • My API key is not authorized.
  • The machine that I'm working on is not authorized.
  • The JS API is not authorized.
  • The company Resend account is not authorized.

If anyone is familiar with Resend, I would deeply appreciate your help.

答案1

得分: 1

根据Resend API文档,401代码的含义是:

401 使用的API密钥缺失。

我希望你代码的第二行是已经隐藏的API密钥,否则将api-key替换为您的有效API密钥应该可以解决问题。

英文:

According to Resend API documentation, the 401 code means:

> 401 The API key used was missing.

I hope that the second line of your code is a redacted api key, otherwise replace the api-key by your valid api key should solve.

huangapple
  • 本文由 发表于 2023年7月7日 07:31:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/76633086.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定