Browse files

add smtp demo

  • Loading branch information...
1 parent c1de14e commit 1ef2e5c1601069a360af146a34a638c18327320b @nomospace committed Aug 15, 2012
Showing with 257 additions and 0 deletions.
  1. +164 −0 .gitignore
  2. BIN demo/attachments/inspectocat.jpg
  3. +11 −0 demo/attachments/notes.txt
  4. +82 −0 demo/test.js
View
164 .gitignore
@@ -0,0 +1,164 @@
+node_modules
+#################
+## Eclipse
+#################
+
+*.pydevproject
+.project
+.metadata
+bin/
+tmp/
+*.tmp
+*.bak
+*.swp
+*~.nib
+local.properties
+.classpath
+.settings/
+.loadpath
+
+# External tool builders
+.externalToolBuilders/
+
+# Locally stored "Eclipse launch configurations"
+*.launch
+
+# CDT-specific
+.cproject
+
+# PDT-specific
+.buildpath
+
+
+#################
+## Visual Studio
+#################
+
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+
+# User-specific files
+*.suo
+*.user
+*.sln.docstates
+
+# Build results
+[Dd]ebug/
+[Rr]elease/
+*_i.c
+*_p.c
+*.ilk
+*.meta
+*.obj
+*.pch
+*.pdb
+*.pgc
+*.pgd
+*.rsp
+*.sbr
+*.tlb
+*.tli
+*.tlh
+*.tmp
+*.vspscc
+.builds
+*.dotCover
+
+## TODO: If you have NuGet Package Restore enabled, uncomment this
+#packages/
+
+# Visual C++ cache files
+ipch/
+*.aps
+*.ncb
+*.opensdf
+*.sdf
+
+# Visual Studio profiler
+*.psess
+*.vsp
+
+# ReSharper is a .NET coding add-in
+_ReSharper*
+
+# Installshield output folder
+[Ee]xpress
+
+# DocProject is a documentation generator add-in
+DocProject/buildhelp/
+DocProject/Help/*.HxT
+DocProject/Help/*.HxC
+DocProject/Help/*.hhc
+DocProject/Help/*.hhk
+DocProject/Help/*.hhp
+DocProject/Help/Html2
+DocProject/Help/html
+
+# Click-Once directory
+publish
+
+# Others
+[Bb]in
+[Oo]bj
+sql
+TestResults
+*.Cache
+ClientBin
+stylecop.*
+~$*
+*.dbmdl
+Generated_Code #added for RIA/Silverlight projects
+
+# Backup & report files from converting an old project file to a newer
+# Visual Studio version. Backup files are not needed, because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+
+
+
+############
+## Windows
+############
+
+# Windows image file caches
+Thumbs.db
+
+# Folder config file
+Desktop.ini
+
+
+#############
+## Python
+#############
+
+*.py[co]
+
+# Packages
+*.egg
+*.egg-info
+dist
+build
+eggs
+parts
+bin
+var
+sdist
+develop-eggs
+.installed.cfg
+
+# Installer logs
+pip-log.txt
+
+# Unit test / coverage reports
+.coverage
+.tox
+
+#Translations
+*.mo
+
+#Mr Developer
+.mr.developer.cfg
+
+# Mac crap
+.DS_Store
View
BIN demo/attachments/inspectocat.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
11 demo/attachments/notes.txt
@@ -0,0 +1,11 @@
+nodemail
+========
+
+?????? web ??????
+
+##????????????
+[nodeMailer](https://github.com/andris9/Nodemailer)
+[simplesmtp](https://github.com/andris9/simplesmtp)
+[mailparser](https://github.com/andris9/mailparser)
+[node-email-templates](https://github.com/niftylettuce/node-email-templates)
+
View
82 demo/test.js
@@ -0,0 +1,82 @@
+var nodemailer = require('nodemailer');
+
+var transport = nodemailer.createTransport("SMTP", {
+ // service: "Gmail",
+ host: "smtp.163.com",
+ // hostname
+ port: 25,
+ // port for secure SMTP
+ auth: {
+ user: "qatest2@163.com",
+ pass: "qa1234"
+ }
+});
+
+console.log('SMTP Configured');
+
+// Message object
+var message = {
+
+ // sender info
+ from: 'qatest2 <qatest2@163.com>',
+
+ // Comma separated list of recipients
+ to: '"jinlu" <jinlu_hz@163.com>',
+
+ // Subject of the message
+ subject: 'Hello nodemail!',
+
+ headers: {
+ 'X-Laziness-level': 1000
+ },
+
+ // plaintext body
+ text: 'Hello nodemail!',
+
+ // HTML body
+ html: '<p><b>Hello nodemail!</b></p><img width="100" src="cid:inspectocat@node"/>',
+
+ // An array of attachments
+ attachments: [
+
+ // String attachment
+ {
+ fileName: 'string.txt',
+ contents: 'Some notes about this e-mail',
+ contentType: 'text/plain' // optional, would be detected from the filename
+ },
+
+ // File attachment
+ {
+ fileName: 'notes.txt',
+ filePath: __dirname + '/attachments/notes.txt',
+ },
+
+ // 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: 'inspectocat.jpg',
+ filePath: __dirname + '/attachments/inspectocat.jpg',
+ cid: 'inspectocat@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!');
+
+ // if you don't want to use this transport object anymore, uncomment following line
+ transport.close(); // close the connection pool
+});

0 comments on commit 1ef2e5c

Please sign in to comment.