{"size": 1420, "ext": "js", "max_stars_repo_path": "snippets/SMTP/smtp_example.js", "max_stars_repo_name": "cjarnold/code-snippets", "max_stars_repo_stars_event_min_datetime": "2015-11-16T18:23:37.000Z", "max_stars_repo_stars_event_max_datetime": "2020-10-20T03:11:40.000Z", "max_issues_repo_path": "snippets/SMTP/smtp_example.js", "max_issues_repo_name": "cjarnold/code-snippets", "max_issues_repo_issues_event_min_datetime": "2015-10-28T15:26:29.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-29T20:42:20.000Z", "max_forks_repo_path": "snippets/SMTP/smtp_example.js", "max_forks_repo_name": "cjarnold/code-snippets", "max_forks_repo_forks_event_min_datetime": "2015-10-27T18:41:01.000Z", "max_forks_repo_forks_event_max_datetime": "2020-03-03T09:21:20.000Z"}
{"max_stars_count": 18, "max_issues_count": 4, "max_forks_count": 13, "avg_line_length": 31.5555555556, "max_line_length": 73, "alphanum_fraction": 0.6992957746}
// This example utilizes the 'nodemailer' and 'nodemailer-smtp-transport'
// modules which can be installed using the following commands:
// npm install nodemailer
// npm install nodemailer-smtp-transport

// Note: nodemailer users looking to switch to the SparkPost
// REST API may be interested in the SparkPost nodemailer transport:
// https://github.com/SparkPost/nodemailer-sparkpost-transport

var nodemailer = require('nodemailer');
var smtpTransport = require('nodemailer-smtp-transport');

var transporter = nodemailer.createTransport(smtpTransport({
      host: 'smtp.sparkpostmail.com',
      port: 587,
      auth: {
        user: 'SMTP_Injection',

        // You will need an API Key with 'Send via SMTP' permissions.
        // Create one here: https://app.sparkpost.com/account/credentials
        pass: '<YOUR API KEY>'
      }
    }));
 
var mailData = {
  // sparkpostbox.com is a sending domain used for testing
  // purposes and is limited to 50 messages per account.
  // Visit https://app.sparkpost.com/account/sending-domains
  // to register and verify your own sending domain.
  from: 'testing@sparkpostbox.com',

  to: 'recipient@example.com',
  subject: 'Testing SparkPost SMTP from Node.js!',
  text: 'Hello World!'
};
 
transporter.sendMail(mailData, function(error, info) {
    if (error) {
      return console.log(error);
    }
    console.log('Message sent: ' + info.response);
  });


