Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Mailing Service
express = require 'express'
skipper = require 'skipper'
nodemailer = require 'nodemailer'
app = express()
verifyToken = (req, res, next) ->
token = req.body.token || req.query.token || req.headers['x-access-token']
if token is process.env.TOKEN
success: false
message: if token then 'No token provided.' else 'Failed to authenticate token.'
transporter = nodemailer.createTransport
pool: true
host: ''
port: 465
secure: true
user: process.env.USER
pass: process.env.PASS
app.use skipper()
app.use verifyToken '*', (req, res) ->
req.file('attachment').upload (err, files) ->
return res.send 500, err if err
data = req.body
data.attachments =
for file in files
filename: file.filename
path: file.fd
transporter.sendMail data, (error, info) ->
if error
console.log error
console.log 'Message sent: ' + info.response
res.send data
module.exports = app
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.