Skip to content

Commit

Permalink
Should store emails as email:key instead of key:Object
Browse files Browse the repository at this point in the history
  • Loading branch information
chadfawcett committed Jan 24, 2015
1 parent d244429 commit 2e8cd01
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ var config = nconf
.file({ file: 'config.json'})
.file('emails', { file: 'emails.json' });

var app = express();
var mandrill_client = new mandrill.Mandrill(config.get('MANDRILL_API_KEY'));
var app = express();

// Needed for 'req.body'
app.use(bodyParser.json());
Expand All @@ -36,24 +36,22 @@ app.post('/', function(req, res) {
return;
}

var recipient = JSON.parse(config.get(req.query.key));
console.log('Attempting to email ' + recipient.email, recipient);

// Create an email message based on post values
var message = {
'text': req.body.message || 'No message was provided',
'subject': req.body._subject || 'Email from NodeMailForm',
'from_email': req.body._replyto,
'from_name': req.body.name,
'to': [{
'email': recipient.email,
'name': recipient.name,
'type': 'to'
},
{
'email': req.body._cc,
'type': 'cc'
}]
'to': [
{
'email': config.get(req.query.key),
'type': 'to'
},
{
'email': req.body._cc,
'type': 'cc'
}
]
}

// Send the message!
Expand Down

0 comments on commit 2e8cd01

Please sign in to comment.