Permalink
Browse files

updated examples

  • Loading branch information...
1 parent ce686cd commit ed88fd1bb6c1c037ef27fc768fae37d54d9b43d0 Andris Reinman committed Feb 9, 2012
Showing with 68 additions and 0 deletions.
  1. +68 −0 examples/example_sendmail.js
  2. BIN examples/nyan.gif
@@ -0,0 +1,68 @@
+var nodemailer = require('../lib/mail');
+
+// Create a Sendmail transport object
+var transport = new nodemailer.Transport("Sendmail", "/usr/sbin/sendmail");
+
+console.log('Sendmail Configured');
+
+// Message object
+var message = {
+
+ // define transport to deliver this message
+ transport: transport,
+
+ // sender info
+ from: 'Sender Name <andris@node.ee>',
+
+ // Comma separated list of recipients
+ to: '"Receiver Name" <andris.reinman@gmail.com>',
+
+ // Subject of the message
+ subject: 'Nodemailer is unicode friendly ✔', //
+
+ // plaintext body
+ text: 'Hello to myself!',
+
+ // HTML body
+ html:'<p><b>Hello</b> to myself <img src="cid:note@node"/></p>'+
+ '<p>Here\'s a nyan cat for you as an embedded attachment:<br/><img src="cid:nyan@node"/></p>',
+
+ // An array of attachments
+ attachments:[
+
+ // String attachment
+ {
+ fileName: 'notes.txt',
+ contents: 'Some notes about this e-mail',
+ contentType: 'text/plain' // optional, would be detected from the filename
+ },
+
+ // Binary Buffer attachment
+ {
+ fileName: 'image.png',
+ contents: new Buffer('iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEUAAAD/' +
+ '//+l2Z/dAAAAM0lEQVR4nGP4/5/h/1+G/58ZDrAz3D/McH8yw83NDDeNGe4U' +
+ 'g9C9zwz3gVLMDA/A6P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC', 'base64'),
+
+ cid: 'note@node' // should be as unique as possible
+ },
+
+ // File Stream attachment
+ {
+ fileName: 'nyan cat ✔.gif',
+ filePath: __dirname+"/nyan.gif",
+ cid: 'nyan@node' // should be as unique as possible
+ }
+ ]
+};
+
+console.log('Sending Mail');
+
+nodemailer.send_mail(message, function(error){
+ if(error){
+ console.log('Error occured');
+ console.log(error.message);
+ return;
+ }
+ console.log('Message sent successfully!');
+});
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ed88fd1

Please sign in to comment.