diff options
author | Cliff Brake <cbrake@bec-systems.com> | 2012-08-17 13:43:14 -0400 |
---|---|---|
committer | Cliff Brake <cbrake@bec-systems.com> | 2012-08-17 13:43:14 -0400 |
commit | a94e78479793722bc97b8771158d1acee3f55413 (patch) | |
tree | bf8f79959febb472513b299df99774de524f5fd1 /tools/node_modules/nodemailer/examples/example_ses.js | |
parent | c11f922b0bfa023a4cf49f26e55aec6a1413344b (diff) | |
download | openembedded-admin-a94e78479793722bc97b8771158d1acee3f55413.tar.gz |
add node modules to git
This is now the best practice for deployed apps
Diffstat (limited to 'tools/node_modules/nodemailer/examples/example_ses.js')
-rw-r--r-- | tools/node_modules/nodemailer/examples/example_ses.js | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/tools/node_modules/nodemailer/examples/example_ses.js b/tools/node_modules/nodemailer/examples/example_ses.js new file mode 100644 index 0000000..5be0586 --- /dev/null +++ b/tools/node_modules/nodemailer/examples/example_ses.js @@ -0,0 +1,80 @@ +var nodemailer = require('../lib/nodemailer'), + fs = require("fs"), + pathlib = require("path"); + +// Create an Amazon SES transport object +var transport = nodemailer.createTransport("SES", { + AWSAccessKeyID: "AWSACCESSKEY", + AWSSecretKey: "/AWS/SECRET", + ServiceUrl: "https://email.us-east-1.amazonaws.com" // optional + }); + +console.log('SES Configured'); + +// optional DKIM signing +/* +transport.useDKIM({ + domainName: "do-not-trust.node.ee", // signing domain + keySelector: "dkim", // selector name (in this case there's a dkim._domainkey.do-not-trust.node.ee TXT record set up) + privateKey: fs.readFileSync(pathlib.join(__dirname,"test_private.pem")) +}); +*/ + +// Message object +var message = { + + // sender info + from: 'Sender Name <sender@example.com>', + + // Comma separated list of recipients + to: '"Receiver Name" <receiver@example.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: 'nyancat.gif', + filePath: __dirname+"/nyan.gif", + cid: 'nyan@node' // should be as unique as possible + } + ] +}; + +console.log('Sending Mail'); + +transport.sendMail(message, function(error){ + if(error){ + console.log('Error occured'); + console.log(error.message); + return; + } + console.log('Message sent successfully!'); +});
\ No newline at end of file |