0

我正在尝试使用我的新 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 错误,简单地说“禁止”。我该如何解决?

4

1 回答 1

1

您的交易账户未激活。在 SendinBlue 支持上创建票证。他们将激活它,您的问题将得到解决。

于 2021-08-13T13:40:23.613 回答