daily pastebin goal
28%
SHARE
TWEET

Untitled

a guest Sep 23rd, 2016 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var nodemailer = require('nodemailer');
  2. //below var smtpTransport not required for Nodemailer version equal or below v0.7.1
  3. var smtpTransport = require("nodemailer-smtp-transport");
  4.  
  5. // Create a SMTP transport object
  6. var transport = nodemailer.createTransport(smtpTransport( {
  7.         host: "smtp.pepipost.com",
  8.         port: 2525,
  9.         auth: {
  10.             user: "yoursmtpusername",
  11.             pass: "yoursmtppassword"
  12.         }
  13.     }));
  14. /*
  15. //Use this code for Nodemailer version equal or below v0.7.1
  16. var transport = nodemailer.createTransport("SMTP", {
  17.         //service: 'Pepipost',
  18.         host: "smtp.pepipost.com",
  19.         port: 2525,
  20.         auth: {
  21.             user: "yoursmtpusername",
  22.             pass: "yoursmtppassword"
  23.         }
  24.     });
  25. */
  26. console.log('SMTP Configured');
  27.  
  28. // Message object
  29. var message = {
  30.  
  31.     // sender info
  32.     from: 'Sender Name <sender@example.com>',
  33.  
  34.     // Comma separated list of recipients
  35.     to: '"Receiver Name" <recipient@example.com>',
  36.  
  37.     // Subject of the message
  38.     subject: 'Nodemailer is unicode friendly ✔',
  39.  
  40.     // plaintext body
  41.     text: 'Test mail sent using Nodemailer with Pepipost',
  42.  
  43.     // HTML body
  44.     html:'<p><b>Hello</b> Test mail sent using Nodemailer with Pepipost</p>'+
  45.          '<p>Thank you.</p>'
  46. };
  47.  
  48. console.log('Sending Mail');
  49. transport.sendMail(message, function(error){
  50.   if(error){
  51.       console.log('Error occured');
  52.       console.log(error.message);
  53.       return;
  54.   }
  55.   console.log('Message sent successfully!');
  56.  
  57.   // if you don't want to use this transport object anymore, uncomment following line
  58.   //transport.close(); // close the connection pool
  59. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top