dileephell

Untitled

Feb 5th, 2014
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var nodemailer = require('nodemailer');
  2.  
  3. module.exports.send_email=function(message,cb){
  4. if (err) {
  5. return cb(err, null);
  6. }
  7.  
  8. if( !null ){
  9. return (message);
  10.  
  11. }
  12. // Create a SMTP transport object
  13. var transport = nodemailer.createTransport("SMTP", {
  14. service: 'Mandrill',
  15. auth: {
  16. user: "mark@*****.com",
  17. pass: "4gHKXAIFdF1KSKcxkixc7g"
  18. }
  19. });
  20.  
  21. console.log('SMTP Configured');
  22.  
  23. // Message object
  24. var message = {
  25.  
  26. // sender info
  27. from: 'Sender Name <mark@*****.com>',
  28.  
  29. // Comma separated list of recipients
  30. to: '"Receiver Name" <[email protected]>',
  31.  
  32. // Subject of the message
  33. subject: 'Nodemailer is unicode friendly ✔', //
  34.  
  35. headers: {
  36. 'X-Laziness-level': 1000
  37. },
  38.  
  39. // plaintext body
  40. text: Dear Sir,
  41.  
  42.  
  43.  
  44. };
  45.  
  46. console.log('Sending Mail');
  47. transport.sendMail(message, function(error){
  48. if(error){
  49. console.log('Error occured');
  50. console.log(error.message);
  51. return;
  52. }
  53. console.log('Message sent successfully!');
  54.  
  55. // if you don't want to use this transport object anymore, uncomment following line
  56. //transport.close(); // close the connection pool
  57. });
  58. }
Advertisement
Add Comment
Please, Sign In to add comment