0

I'm trying send a e-mail but I only receive bad-request message. Just it. This is my code.

const request = require('request');
var options = {
    url: 'https://ln....api.infobip.com/email/1/send',
    reqType: "POST",
    json:{
      from: 'Sender Name <rodr...mail.com>',
      to: 'cop@sd1....com',
      subject: 'Test Subject',
      text: 'Sample Email Body',
    },
    headers: {
      'Authorization': 'App ca8c0e09e3ad4058f5b462e314c...bb76',
      'Content-Type': 'application/json',
      'Accept': 'application/json'
    }
}

request.post(options,(errReq, resp) => {
        if (errReq){
          return console.error(errReq);
        }


        console.log(`Status code: ${resp.statusCode}. Message: ${JSON.stringify(resp)}`);
});

Log-part1

Log-part2

If I try send sms with a similar code:

const request = require('request');

const options = {
  url: 'https://ln....api.infobip.com/sms/2/text/single',
  json: {
    from: 'Infobip',
    to: '55739916...',
    text: 'Teste'
},
  headers: {
    'Authorization': 'App ca8c0e09e3ad4058f5b462e...',
    'Content-Type': 'application/json',
    'Accept': 'application/json'
  }
}

request.post(options,(err, response) => {
  if (err){
    return console.log(err)
  }

  console.log(`Status code: ${response.statusCode}. Message: ${response.body}`);
});

it works fine. I don't have idea what I'm making wrong to send e-mail. Can someone help me please?

An example in infobip api: Infobip

My client receive this messagem from support: "I made our test domain available: s...email..hub.com This way you can perform shots with for example: cop@s...email..hub.com (or any other variable before @), I've also added 50 email shots so you can test."

Did I miss something in the code?

msmolcic
  • 6,407
  • 8
  • 32
  • 56
rodrigofbm
  • 31
  • 1
  • 6

1 Answers1

0

Do you use the domain which they provided? Maybe you can try with their domain :

from: 'Sender Name**'

If you want to use with your company email domain, you should the ask account manager to add your company email domain to their platform.