英文:
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 '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()
When I run the code above, I get the following exception:
{
name: 'validation_error',
message: 'Not authorized to send emails from <companydomain>',
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论