Permalink
Browse files

update app to send mail

  • Loading branch information...
1 parent 2ddcec9 commit ce441c3e5e356ab2314effe4c159080c4012f86f @cbrake committed Sep 4, 2012
Showing with 49 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +24 −0 app.js
  3. +24 −0 config-example.js
View
@@ -0,0 +1 @@
+config.js
View
24 app.js
@@ -1,8 +1,12 @@
var express = require('express')
var fs = require('fs')
+var nodemailer = require('nodemailer')
+var config = require('./config').config
var app = express()
+var transport = nodemailer.createTransport(config.email.transport.type, config.email.transport.options)
+
app.configure(function() {
app.use(app.router)
app.use('/', express.static(__dirname + '/public'))
@@ -14,6 +18,26 @@ app.get('/', function(req, res) {
})
})
+app.get('/send-mail', function(req, res) {
+
+ var mailOptions = {
+ from: config.email.from,
+ to: config.email.to,
+ subject: "test message"
+ }
+
+
+ transport.sendMail(mailOptions, function(error, response) {
+ if (error) {
+ console.log(error)
+ res.send('Error sending mail: ' + error)
+ } else {
+ console.log("Message sent: " + response.message)
+ res.send('Message sent: ' + response.message)
+ }
+ })
+})
+
app.listen(process.env.VMC_APP_PORT || 1377, null)
//app.listen(3030)
View
@@ -0,0 +1,24 @@
+// copy this to config.js and modify
+
+exports.config = {
+ // see https://github.com/andris9/Nodemailer for more information on email options
+ email : {
+ transport: {
+ type: 'SMTP',
+ options: {
+ service: 'Gmail',
+ auth: {
+ user: 'gmail.user@gmail.com',
+ pass: 'my gmail pass'
+ }
+ }
+ },
+ from: 'user@mydomain.com',
+ // You can typically send text messages to a phone by using an email address like:
+ // phonenumber@txt.att.net
+ // phonenumber@vtext.com
+ // phonenumber@tmomail.net
+ to: 'user1@mydomain.com, 1234567890@txt.att.net'
+ }
+}
+

0 comments on commit ce441c3

Please sign in to comment.