MarcosEllys/awesome-newman-html-template

Email Awesome report

Opened this issue · 2 comments

Hi Marcos,

Help me here like with cmd line integrationif newman need to send the report generated automatically from my email to others in both est and ist timezones

Hi @Subhashini-1, sure i will help you, if you want send a email do you need recover response in a script like this:

const newman = require('newman');
const Mailgun = require('mailgun-js');
const mailgunApiKey = 'mailgunApiKey';
const mailgunDomain = 'mailgunDomain';
const from_who = 'Marcos Ellys <my@email.com>';
 
newman.run({
  collection: __dirname + '/collection.json',
  environment: __dirname + '/environment.json',
  globals: __dirname + '/globals.json',
  reporters: ['html'],
  reporter: {
    html: { export: '/path/to/export/report.html', template: __dirname + '/htmlreqres.hbs' } }
}, function (err, summary) {
  if (err) { throw err; }
   
  if (summary.run.stats.assertions.failed) {
    const mailgun = new Mailgun({apiKey: mailgunApiKey, domain: mailgunDomain});
    const mailData = {
      //Specify email data
        from: from_who,
      //The email to contact
        to: 'Marcos Ellys <marcos.ellys@gmail.com>',
      //Subject and text data  
        subject: 'Errors in my system',
        html: summary.run.stats.assertions.failed + ' some tests fail!'
      }
 
    mailgun.messages().send(mailData, function (err) {
      if (err) {
        console.log("got an error: ", err);
      }
    });
  }
});

In this example i generated the template and send a email with errors information, in my job, i used a lot MailGun for make this

Thanks Marcos.I have implemented with the insights you have provided