вот ответ с ошибкой:
{
[0] id: 300703,
[0] name: 'My emails',
[0] all_email_qty: 1,
[0] active_email_qty: 1,
[0] inactive_email_qty: 0,
[0] new_phones_quantity: 0,
[0] active_phones_quantity: 0,
[0] exc_phones_quantity: 0,
[0] creationdate: '2022-05-03 03:27:47',
[0] status: 0,
[0] status_explain: 'Active'
[0] }
[0] ]
[0] { message: 'Sender is not valid', error_code: 422 }
Код:
let sendpulse = require("sendpulse-api");
module.exports = function sendMail() {
const sendpulse = require('sendpulse-api');
const SENDPULSE_USER_ID = '*****************************';
const SENDPULSE_SECRET = '******************************';
const API_USER_ID = SENDPULSE_USER_ID;
const API_SECRET = SENDPULSE_SECRET;
const SENDER_NAME = 'Tima';
const EMAIL_FROM = 'izajcev997@gmail.com';
const TOKEN_STORAGE = "./tmp/";
sendpulse.init(API_USER_ID,API_SECRET,TOKEN_STORAGE, function(token){
function answerGetter(data){
console.log(data);
};
let email = {
"html" : "<h1>Example text</h1>",
"text" :"Example text",
"subject" : "Example subject",
"from" : {
"name" : "Vasia",
"email" : 'izajcev997@gmail.com'
},
"to" : [
{
"name" : "triabogin@gmail.com",
"email" : "triabogin@gmail.com"
},
],
"bcc" : []
};
sendpulse.listAddressBooks(answerGetter);
sendpulse.smtpSendMail(answerGetter,email);
});
и в index.js вызываю его
app.get('/sendmail', (req, res, next)=>{
sendMail()
res.send('добрый вечер')
})
Токен появляется в tmp