Skip to content

Commit

Permalink
Add Email Functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
RychardHunt committed Nov 5, 2017
1 parent 6b58b49 commit 10552e5
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 6 deletions.
2 changes: 2 additions & 0 deletions api/app.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const express = require('express')
const app = express()
const bodyParser = require('body-parser')
app.use(bodyParser())
app.all('*', (req, res) => {
return res.send('unauthorized request')
})
Expand Down
5 changes: 5 additions & 0 deletions api/classes/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const mail = require('./mail')

module.exports = {
mail: mail
}
5 changes: 1 addition & 4 deletions api/classes/mail.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,11 @@ class Mail {
const that = this
return new Promise(function(resolve, reject) {
var data = {
from: config.constants.developer_name + '<' + that.from + '>',
from: config.constants.appName + '<' + that.from + '>',
to: that.to,
subject: that.subject,
html: that.content
}
if (config.constants.env !== 'production') { //Only send emails while in production
resolve("Sent!")
}
mailgun.messages().send(data, function(error, body) {
if (error) {
reject()
Expand Down
1 change: 1 addition & 0 deletions api/config/constants.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const constants = {
appName: "On the Block"
noReplyEmail: 'noreply@sandboxd231c3377fcf4941b5e539cb598f444f.mailgun.org'
}

module.exports = constants
17 changes: 17 additions & 0 deletions api/controllers/proposal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
controllers/proposal.js
Descriptiion: Buyer sends Proposal to Seller's Email
*/

const classes = require('../classes')
const config = require('../config')

@// TODO: Get Information from Solidity Smart Contract Back End
module.exports = function(req, res) {
mail = new classes.mail(
config.constants.noReplyEmail,
'charlie@charliecampanlla.com',
'New Property Offer',
'Are you willing to sell your property for '
)
}
4 changes: 3 additions & 1 deletion api/util/errors/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const fatal = require('./fatal')

module.export = fatal
module.exports = {
fatal: fatal
}
4 changes: 3 additions & 1 deletion api/util/validation/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const types = require('./types')

module.export = types
module.exports = {
types: types
}

0 comments on commit 10552e5

Please sign in to comment.