Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

181 send emails as plain text #193

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/entryController.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ exports.verifyEntry = function (request, response) {
exports.disableEntry = function (request, response) {
db.getUserByHash(request.params.k, function (results, err) {
if (!err) {
ejs.renderFile(__dirname + "/../templates/delete-confirm.ejs", { hash : request.params.k }, function (err, data) {
ejs.renderFile(__dirname + "/../templates/deleteConfirm.ejs", { hash : request.params.k }, function (err, data) {
if (err) {
response.writeHead(404);
response.write('Whoops! File not found!');
Expand Down
58 changes: 24 additions & 34 deletions core/mailer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

let nodeMailer = require('nodemailer'),
ejs = require("ejs"),
transporter = undefined;
transporter = undefined,
fs = require('fs'),
path = require("path");


function initTransporter(){
Expand All @@ -19,42 +21,31 @@ function initTransporter(){
}
}

exports.sendVerifySuccess = function(recipient){
exports.sendVerificationMail = function(key, recipient, callback = null){
initTransporter();

ejs.renderFile(__dirname + "/../mails/entry/verifySuccess.ejs", { firstname : recipient.firstname }, function (err, data) {
if (err) {
console.log(err);
} else {
let mailOptions = {
from: '"Human Connection - Uhr des Wandels" <[email protected]>', // sender address
to: recipient.email, // list of receivers
subject: "Deine E-Mail Adresse wurde bestätigt!", // Subject line
html: data // html body
};

transporter.sendMail(mailOptions, (error, info) => {
if (error) {
return console.log(error);
}
console.log('Message %s sent: %s', info.messageId, info.response);
});
}
});
};
const replacementVariables = {
'{{{firstname}}}': recipient.firstname,
'{{{key}}}': key
};

fs.readFile(
path.resolve(__dirname + '/../mails/entry/registerSuccess.txt'),
'utf8',
function(error, data) {
if (error) {
throw error;
}

exports.sendVerificationMail = function(key, recipient, callback = null){
initTransporter();
for (const [key, value] of Object.entries(replacementVariables)) {
data = data.replace(new RegExp(key, 'g'), value)
}

ejs.renderFile(__dirname + "/../mails/entry/verify.ejs", { key: key, firstname : recipient.firstname }, function (err, data) {
if (err) {
console.log(err);
} else {
let mailOptions = {
from: '"Human Connection Clock" <[email protected]>', // sender address
const mailOptions = {
from: '"Human Connection Clock" <[email protected]>', // sender address
to: recipient.email, // list of receivers
subject: "Human Connection Uhr Eintrag erfolgeich", // Subject line
html: data // html body
subject: "Human Connection Clock entry successful", // Subject line
text: data,
};

transporter.sendMail(mailOptions, (error, info) => {
Expand All @@ -63,6 +54,5 @@ exports.sendVerificationMail = function(key, recipient, callback = null){
}
console.log('Message %s sent: %s', info.messageId, info.response);
});
}
});
})
};
25 changes: 25 additions & 0 deletions mails/entry/registerSuccess.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Hallo {{{firstname}}},

WILLKOMMEN bei der Human Connection-Uhr! VIELEN DANK, dass Du mit dabei bist! Zusammen setzen wir ein Zeichen! Wenn du deinen Eintrag deaktivieren möchtest, klicke bitte auf den folgende Link:

https://api.clockofchange.org/entries/disable/{{{key}}}

Wir würden uns sehr über Deine Unterstützung freuen! Mit einer einmaligen oder monatlichen Spende kannst du unsere Arbeit unterstützen.
Human Connection ist wegen Förderung internationaler Gesinnung, der Toleranz auf allen Gebieten der Kultur und des Völkerverständigungsgedankens als gemeinnützig anerkannt. Alle Spenden dienen dem Gemeinwohl.

UNTERSTÜTZE UNSERE ARBEIT - https://human-connection.org/spenden/

Es gibt jetzt außerdem die Möglichkeit die Human Connection-Uhr als lebensechtes Modell zum Aufstellen vorzubestellen - erfahre mehr unter https://human-connection.org/vorbestellen/

BANKVERBINDUNG
GLS Bank
IBAN: DE08 4306 0967 7024 1934 00
BIC / SWIFT: GENODEM1GLS

Kennst Du schon das Förderprogramm von Human Connection? Als Förderer können Sie Ihren ganz besonderen Beitrag leisten und sich zusammen mit uns für ein gesellschaftliches, besseres Miteinander einsetzen.

FÖRDERER WERDEN - https://human-connection.org/foerderer-werden/

CEO und Gründer: Dennis Hack - Registergericht Stuttgart - HRB 741951
Steuernummer: 69042/06453 VAT-ID: DE284651760
www.human-connection.org - [email protected]
Empty file removed public/.gitignore
Empty file.
Binary file added public/images/de.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/en.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/es.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/fr.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const app = express();
// config
app.set('view engine', 'ejs');
app.use('/uploads', express.static(__dirname + '/uploads'));
app.use(express.static(__dirname + '/public'));
app.use(bodyParser.urlencoded({
extended: false
}));
Expand Down
62 changes: 0 additions & 62 deletions templates/delete-confirm.ejs

This file was deleted.

125 changes: 125 additions & 0 deletions templates/deleteConfirm.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
<title>Human Connection Clock - Delete Entry</title>
<!--[if lt IE 9]>
<script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<style>
@import 'https://fonts.googleapis.com/css?family=Roboto:300,400,500';

body {
margin: 0 auto;
max-width: 50em;
font-family: "Roboto", "Helvetica", "Arial", sans-serif;
font-size: 18px;
line-height: 1.5;
padding: 4em 1em;
color: #555;
}

h1, h2 {
margin-top: 1em;
padding-top: 1em;
color: #333;
}

p {
margin-top: 0.25em;
margin-bottom: 0.25em;
}

hr {
border-color: #eee;
}

.btn {
font-size: 18px;
padding: 0.75em;
margin-right: 1em;
border-radius: 3px;
}
.btn-primary {
background-color: #e81c4f;
border: #c41540;
color: #ffffff;
}
#logo {
text-align: center;
}

.message-wrapper {
display: flex;
flex-direction: row;
align-items: center;
margin: 2em 0;
}
.message-image {
height: 50px;
margin-right: 30px;
}
.message-image img {
object-fit: contain;
max-height: 50px;
border-radius: 5px;
}
</style>
</head>
<body>
<div id="logo">
<a href="https://human-connection.org/">
<img src="https://human-connection.org/wp-content/uploads/2019/12/HC-Logo-2020_Square_website_100x100px.svg"
srcset="https://human-connection.org/wp-content/uploads/2019/12/HC-Logo-2020_Square_website_100x100px.svg 1x"
alt="Human Connection Logo" data-retina_logo_url="" class="fusion-standard-logo" width="" height="">
</a>
</div>
<main>
<h1>Human Connection Clock - Delete Entry</h1>
<div class="message-wrapper">
<div class="message-image">
<img src="/images/en.png" alt="English" title="English">
</div>
<div>
<p>You are about to delete your entry for the Human Connection Clock.</p>
<p>When you proceed, all data will be deleted and can't be recovered.</p>
</div>
</div>
<hr>
<div class="message-wrapper">
<div class="message-image">
<img src="/images/fr.png" alt="English" title="Francais">
</div>
<div>
<p>Vous êtes en train de supprimer votre saisie pour l'horloge Human Connection </p>
<p>Si vous continuez, toutes vos données seront effacées et ne pourront pas être récupérées</p>
</div>
</div>
<hr>
<div class="message-wrapper">
<div class="message-image">
<img src="/images/es.png" alt="English" title="Espanyol">
</div>
<div>
<p>Está a punto de borrar su entrada por el reloj Human Connection </p>
<p>Cuando proceda, todos los datos serán borrados y no podrán ser recuperados.</p>
</div>
</div>
<hr>
<div class="message-wrapper">
<div class="message-image">
<img src="/images/de.png" alt="English" title="Deutsch">
</div>
<div>
<p>Sie sind dabei Ihren Eintrag für die Human Connection Uhr zu löschen.</p>
<p>Wenn Sie fortfahren werden alle Ihre Daten gelöscht und können nicht wieder hergestellt werden.</p>
</div>
</div>
<br>
<p>
<a href="/entries/disable-delete/<%= hash %>"><button class="btn btn-primary">Delete / Supprimer / Borrar / Löschen</button></a>
<a href="https://human-connection.org/"><button class="btn btn-secondary">Abort / Abandonner / Abortar / Abbrechen</button></a>
</p>
</main>
</body>
</html>