Advertisement
rodrigofbm

Untitled

Nov 30th, 2018
499
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const https = require('https')
  2.  
  3. const data = JSON.stringify({
  4.     'from': 'Rodrigo <rodrigo_fbm@hotmail.com>',
  5.     'to': 'rodrcle@gmail.com',
  6.     'subject': 'Test Subject',
  7.     'html': '<h1>Html body</h1><p>Rich HTML message body.</p>',
  8.     'text': 'Sample Email Body',
  9.     'intermediateReport': 'true'
  10. })
  11.  
  12. const options = {
  13.   hostname: '{base_url}.api.infobip.com',
  14.   port: 443,
  15.   path: '/email/1/send',
  16.   method: 'POST',
  17.   headers: {
  18.     'Content-Type': 'application/json',
  19.     'Accept': 'application/json',
  20.     'Content-Length': data.length,
  21.     'Authorization': 'Basic Y29wLnNlZ3VyYW...='
  22.   }
  23. }
  24.  
  25. const req = https.request(options, (res) => {
  26.   console.log(`statusCode: ${res.statusCode}`)
  27.  
  28.   res.on('data', (d) => {
  29.     process.stdout.write(d)
  30.   })
  31. })
  32.  
  33. req.on('error', (error) => {
  34.   console.error(error)
  35. })
  36.  
  37. req.write(data)
  38. req.end()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement