added email notification support for general smtp and mailgun
parent
46f2bcf1ec
commit
2bdeb81979
@ -1,41 +0,0 @@
|
||||
var express = require('express');
|
||||
var router = express.Router();
|
||||
var api_key = 'key-4ef13da32fb39b9d9f0370c9efba7f06';
|
||||
var domain = 'communique.playvicio.us';
|
||||
var mailgun = require('mailgun-js')({
|
||||
apiKey: api_key,
|
||||
domain: domain
|
||||
});
|
||||
|
||||
router.post('/', function (req, res, next) {
|
||||
|
||||
|
||||
// create reusable transporter object using the default SMTP transport
|
||||
|
||||
// setup e-mail data with unicode symbols
|
||||
var mailOptions = {
|
||||
from: req.body.email, // sender address
|
||||
to: 'ro@playvicio.us', // list of receivers
|
||||
subject: 'Availability Inquiry', // Subject line
|
||||
text: "Message from: " + req.body.client + " <" + req.body.email + "> - " + req.body.description + " - " + req.body.type
|
||||
};
|
||||
|
||||
mailgun.messages().send(mailOptions, function (error, body) {
|
||||
|
||||
if (error) {
|
||||
res.json({
|
||||
error: error
|
||||
});
|
||||
}
|
||||
console.log(body);
|
||||
res.json({
|
||||
message: "message sent"
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
module.exports = router;
|
@ -0,0 +1,82 @@
|
||||
var express = require('express');
|
||||
var router = express.Router();
|
||||
var nodemailer = require('nodemailer');
|
||||
var mg = require('nodemailer-mailgun-transport');
|
||||
const fs = require('fs-extra');
|
||||
const pug = require('pug');
|
||||
router.post('/', function(req, res, next)
|
||||
{
|
||||
fs.readJson('config/site-settings.json').then(settings =>
|
||||
{
|
||||
let transport = ''
|
||||
switch (settings.email.active)
|
||||
{
|
||||
case "option-smtp":
|
||||
var auth = {
|
||||
host: settings.email.smtp.domain,
|
||||
port: 587,
|
||||
secure: false,
|
||||
auth:
|
||||
{
|
||||
type:"login",
|
||||
email: settings.email.smtp,
|
||||
password: settings.email.smtp.password
|
||||
}
|
||||
}
|
||||
transport = nodemailer.createTransport((auth));
|
||||
break;
|
||||
case "option-mg":
|
||||
var auth = {
|
||||
auth:
|
||||
{
|
||||
api_key: settings.email.mailgun['api-key'],
|
||||
domain: settings.email.mailgun.domain
|
||||
}
|
||||
}
|
||||
transport = nodemailer.createTransport(mg(auth));
|
||||
break
|
||||
}
|
||||
let render = pug.compileFile('themes/dash/email/base.pug');
|
||||
let html = render(
|
||||
{
|
||||
title: settings.title,
|
||||
header: "a note from " + settings.title,
|
||||
content: req.body.content,
|
||||
footer: "powered by fipamo"
|
||||
})
|
||||
transport.sendMail(
|
||||
{
|
||||
from: 'control@playvico.us',
|
||||
to: 'are0h@protonmail.com', // An array if you have multiple recipients.
|
||||
subject: 'Hey beautiful',
|
||||
//You can use "html:" to send HTML email content. It's magic!
|
||||
html: html
|
||||
//You can use "text:" to send plain-text content. It's oldschool!
|
||||
//text: 'Mailgun rocks, pow pow!'
|
||||
}, function(err, info)
|
||||
{
|
||||
if (err)
|
||||
{
|
||||
console.log(err)
|
||||
res.json(
|
||||
{
|
||||
message: "MAIL ERROR",
|
||||
desc: err
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
console.log(info)
|
||||
res.json(
|
||||
{
|
||||
message: "MAIL SENT",
|
||||
desc: info
|
||||
});
|
||||
}
|
||||
});
|
||||
}).catch(err =>
|
||||
{
|
||||
console.error(err)
|
||||
})
|
||||
});
|
||||
module.exports = router;
|
@ -0,0 +1,139 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Email title or subject</title>
|
||||
|
||||
<style type="text/css">
|
||||
/* reset */
|
||||
#outlook a {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
/* Force Outlook to provide a "view in browser" menu link. */
|
||||
.ExternalClass {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* Force Hotmail to display emails at full width */
|
||||
.ExternalClass,
|
||||
.ExternalClass p,
|
||||
.ExternalClass span,
|
||||
.ExternalClass font,
|
||||
.ExternalClass td,
|
||||
.ExternalClass div {
|
||||
line-height: 100%;
|
||||
}
|
||||
|
||||
/* Forces Hotmail to display normal line spacing. More on that: http://www.emailonacid.com/forum/viewthread/43/ */
|
||||
p {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-size: 0px;
|
||||
line-height: 0px;
|
||||
}
|
||||
|
||||
/* squash Exact Target injected paragraphs */
|
||||
table td {
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
/* Outlook 07, 10 padding issue fix */
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
mso-table-lspace: 0pt;
|
||||
mso-table-rspace: 0pt;
|
||||
}
|
||||
|
||||
/* remove spacing around Outlook 07, 10 tables */
|
||||
|
||||
/* bring inline */
|
||||
img {
|
||||
display: block;
|
||||
outline: none;
|
||||
text-decoration: none;
|
||||
-ms-interpolation-mode: bicubic;
|
||||
}
|
||||
|
||||
a img {
|
||||
border: none;
|
||||
}
|
||||
|
||||
a {
|
||||
text-decoration: none;
|
||||
color: #000001;
|
||||
}
|
||||
|
||||
/* text link */
|
||||
a.phone {
|
||||
text-decoration: none;
|
||||
color: #000001 !important;
|
||||
pointer-events: auto;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
/* phone link, use as wrapper on phone numbers */
|
||||
span {
|
||||
font-size: 13px;
|
||||
line-height: 17px;
|
||||
font-family: monospace;
|
||||
color: #000001;
|
||||
}
|
||||
</style>
|
||||
<!--[if gte mso 9]>
|
||||
<style>
|
||||
/* Target Outlook 2007 and 2010 */
|
||||
</style>
|
||||
<![endif]-->
|
||||
</head>
|
||||
|
||||
<body style="width:100%; margin:0; padding:0; -webkit-text-size-adjust:100%; -ms-text-size-adjust:100%; background: #161d23;">
|
||||
|
||||
<!-- body wrapper -->
|
||||
<table cellpadding="0" cellspacing="0" border="0" style="margin:0; padding:0; width:100%; line-height: 100% !important;">
|
||||
<tr>
|
||||
<td valign="top">
|
||||
<!-- edge wrapper -->
|
||||
<table cellpadding="0" cellspacing="0" border="0" align="center" width="600" style="background: #374857;">
|
||||
<tr>
|
||||
<td valign="top" style="vertical-align: top;">
|
||||
<!-- ///////////////////////////////////////////////////// -->
|
||||
|
||||
<table cellpadding="0" cellspacing="0" border="0" align="center" style="width:100%">
|
||||
<tr>
|
||||
<td valign="top" style="vertical-align: top;text-align: center; padding: 10px">
|
||||
<span style="font-family: Arial,Helvetica Neue,Helvetica,sans-serif; color:#f5ab35; font-size:20px; font-weight: bold;">
|
||||
HEADER
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top" style="vertical-align: top; background: #161d23; padding:10px;">
|
||||
<span style="font-family: Arial,Helvetica Neue,Helvetica,sans-serif; color:#cecece; font-size:16px;">
|
||||
BIG BODY
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top" style="vertical-align: top; padding: 10px;">
|
||||
<span style="font-family: Arial,Helvetica Neue,Helvetica,sans-serif; color:#b2cce5; font-size:12px;">
|
||||
footer text
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<!-- //////////// -->
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<!-- / edge wrapper -->
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<!-- / page wrapper -->
|
||||
</body>
|
||||
|
||||
</html>
|
File diff suppressed because one or more lines are too long
@ -0,0 +1,94 @@
|
||||
doctype strict
|
||||
head
|
||||
meta(http-equiv='Content-Type' content='text/html; charset=utf-8')
|
||||
meta(name='viewport' content='width=device-width, initial-scale=1.0')
|
||||
title #{title}
|
||||
style(type='text/css').
|
||||
/* reset */
|
||||
#outlook a {
|
||||
padding: 0;
|
||||
}
|
||||
/* Force Outlook to provide a "view in browser" menu link. */
|
||||
.ExternalClass {
|
||||
width: 100%;
|
||||
}
|
||||
/* Force Hotmail to display emails at full width */
|
||||
.ExternalClass,
|
||||
.ExternalClass p,
|
||||
.ExternalClass span,
|
||||
.ExternalClass font,
|
||||
.ExternalClass td,
|
||||
.ExternalClass div {
|
||||
line-height: 100%;
|
||||
}
|
||||
/* Forces Hotmail to display normal line spacing. More on that: http://www.emailonacid.com/forum/viewthread/43/ */
|
||||
p {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
font-size: 0px;
|
||||
line-height: 0px;
|
||||
}
|
||||
/* squash Exact Target injected paragraphs */
|
||||
table td {
|
||||
border-collapse: collapse;
|
||||
}
|
||||
/* Outlook 07, 10 padding issue fix */
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
mso-table-lspace: 0pt;
|
||||
mso-table-rspace: 0pt;
|
||||
}
|
||||
/* remove spacing around Outlook 07, 10 tables */
|
||||
/* bring inline */
|
||||
img {
|
||||
display: block;
|
||||
outline: none;
|
||||
text-decoration: none;
|
||||
-ms-interpolation-mode: bicubic;
|
||||
}
|
||||
a img {
|
||||
border: none;
|
||||
}
|
||||
a {
|
||||
text-decoration: none;
|
||||
color: #000001;
|
||||
}
|
||||
/* text link */
|
||||
a.phone {
|
||||
text-decoration: none;
|
||||
color: #000001 !important;
|
||||
pointer-events: auto;
|
||||
cursor: default;
|
||||
}
|
||||
/* phone link, use as wrapper on phone numbers */
|
||||
span {
|
||||
font-size: 13px;
|
||||
line-height: 17px;
|
||||
font-family: monospace;
|
||||
color: #000001;
|
||||
}
|
||||
//if gte mso 9
|
||||
style.
|
||||
/* Target Outlook 2007 and 2010 */
|
||||
// body wrapper
|
||||
table(cellpadding='0' cellspacing='0' border='0' style='margin:0; padding:0; width:100%; line-height: 100% !important;')
|
||||
tr
|
||||
td(valign='top')
|
||||
// edge wrapper
|
||||
table(cellpadding='0' cellspacing='0' border='0' align='center' width='600' style='background: #374857;')
|
||||
tr
|
||||
td(valign='top' style='vertical-align: top;')
|
||||
// /////////////////////////////////////////////////////
|
||||
table(cellpadding='0' cellspacing='0' border='0' align='center' style='width:100%')
|
||||
tr
|
||||
td(valign='top' style='vertical-align: top;text-align: center; padding: 10px')
|
||||
span(style='font-family: Arial,Helvetica Neue,Helvetica,sans-serif; color:#f5ab35; font-size:20px; font-weight: bold;')
|
||||
| #{header}
|
||||
tr
|
||||
td(valign='top' style='vertical-align: top; background: #161d23; padding:10px;')
|
||||
span(style='font-family: Arial,Helvetica Neue,Helvetica,sans-serif; color:#cecece; font-size:16px;')
|
||||
| #{content}
|
||||
tr
|
||||
td(valign='top' style='vertical-align: top; padding: 10px;')
|
||||
span(style='font-family: Arial,Helvetica Neue,Helvetica,sans-serif; color:#b2cce5; font-size:12px;')
|
||||
| #{footer}
|
Loading…
Reference in New Issue