SendInBlue - sib-api-v3-sdk sendTransacEmail() returns 403 禁止
SendInBlue - sib-api-v3-sdk sendTransacEmail() returns 403 Forbidden
我正在尝试使用我的新 SendInBlue 帐户发送交易电子邮件,但我一直收到一条错误消息,仅显示“禁止”。我按照 SendInBlue 的 Nodejs 文档中的示例编写了这段代码:
const SibApiV3Sdk = require('sib-api-v3-sdk');
const defaultClient = SibApiV3Sdk.ApiClient.instance;
// Configure API key authorization: api-key
const apiKey = defaultClient.authentications['api-key'];
apiKey.apiKey = 'xxx';
// Uncomment the following line to set a prefix for the API key, e.g. 'Token' (defaults to null)
//apiKey.apiKeyPrefix = 'Token'
// Configure API key authorization: partner-key
//const partnerKey = defaultClient.authentications['partner-key'];
//partnerKey.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. 'Token' (defaults to null)
//partnerKey.apiKeyPrefix['partner-key'] = 'Token'
const apiInstance = new SibApiV3Sdk.TransactionalEmailsApi();
const sendSmtpEmail = new SibApiV3Sdk.SendSmtpEmail(); // SendSmtpEmail | Values to send a transactional email
const sendEmail = async (to, subject, htmlBody, textBody) => {
sendSmtpEmail.to = [{ email: to }];
sendSmtpEmail.sender = { email: 'voluntime.aryanm@gmail.com', name: 'Voluntime' };
sendSmtpEmail.htmlContent = `<html><body style='text-align:center'><strong>Voluntime</strong><br><br><p style='width:90%;padding-left:5%;padding-right:5%'>${htmlBody}</p><br><br>You can update your email preferences for <a href='https://voluntime.mittaldev.com'>Voluntime</a> in the Account page.<br><span style='opacity:0'>${Date.now()}</span></body></html>`;
sendSmtpEmail.textContent = `Voluntime:\n\n${textBody}\n\nYou can update your email preferences for Voluntime in the Account page.\n\nTimestamp: ${Date.now()}`;
sendSmtpEmail.subject = `Voluntime - ${subject}`;
sendSmtpEmail.replyTo = { email: 'voluntime.aryanm@gmail.com' };
const result = await apiInstance.sendTransacEmail(sendSmtpEmail);
console.log(result);
return result;
};
export { sendEmail };
apiInstance.sendTransacEmail(sendSmtpEmail)
行抛出 403 错误,仅显示“Forbidden”。我该如何解决这个问题?
您的交易账户未激活。在 SendinBlue 支持上创建票证。他们会激活它,您的问题就会得到解决。
我正在尝试使用我的新 SendInBlue 帐户发送交易电子邮件,但我一直收到一条错误消息,仅显示“禁止”。我按照 SendInBlue 的 Nodejs 文档中的示例编写了这段代码:
const SibApiV3Sdk = require('sib-api-v3-sdk');
const defaultClient = SibApiV3Sdk.ApiClient.instance;
// Configure API key authorization: api-key
const apiKey = defaultClient.authentications['api-key'];
apiKey.apiKey = 'xxx';
// Uncomment the following line to set a prefix for the API key, e.g. 'Token' (defaults to null)
//apiKey.apiKeyPrefix = 'Token'
// Configure API key authorization: partner-key
//const partnerKey = defaultClient.authentications['partner-key'];
//partnerKey.apiKey = 'YOUR API KEY';
// Uncomment the following line to set a prefix for the API key, e.g. 'Token' (defaults to null)
//partnerKey.apiKeyPrefix['partner-key'] = 'Token'
const apiInstance = new SibApiV3Sdk.TransactionalEmailsApi();
const sendSmtpEmail = new SibApiV3Sdk.SendSmtpEmail(); // SendSmtpEmail | Values to send a transactional email
const sendEmail = async (to, subject, htmlBody, textBody) => {
sendSmtpEmail.to = [{ email: to }];
sendSmtpEmail.sender = { email: 'voluntime.aryanm@gmail.com', name: 'Voluntime' };
sendSmtpEmail.htmlContent = `<html><body style='text-align:center'><strong>Voluntime</strong><br><br><p style='width:90%;padding-left:5%;padding-right:5%'>${htmlBody}</p><br><br>You can update your email preferences for <a href='https://voluntime.mittaldev.com'>Voluntime</a> in the Account page.<br><span style='opacity:0'>${Date.now()}</span></body></html>`;
sendSmtpEmail.textContent = `Voluntime:\n\n${textBody}\n\nYou can update your email preferences for Voluntime in the Account page.\n\nTimestamp: ${Date.now()}`;
sendSmtpEmail.subject = `Voluntime - ${subject}`;
sendSmtpEmail.replyTo = { email: 'voluntime.aryanm@gmail.com' };
const result = await apiInstance.sendTransacEmail(sendSmtpEmail);
console.log(result);
return result;
};
export { sendEmail };
apiInstance.sendTransacEmail(sendSmtpEmail)
行抛出 403 错误,仅显示“Forbidden”。我该如何解决这个问题?
您的交易账户未激活。在 SendinBlue 支持上创建票证。他们会激活它,您的问题就会得到解决。