From aa847860a9ba8e49d7498741709603035c9917df Mon Sep 17 00:00:00 2001 From: Andris Reinman Date: Wed, 9 Aug 2017 13:29:50 +0300 Subject: [PATCH] updated sample email --- emails/example.html | 8 +++++--- lib/tools.js | 10 +++++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/emails/example.html b/emails/example.html index 6e4dd30b..782d7886 100644 --- a/emails/example.html +++ b/emails/example.html @@ -87,18 +87,20 @@ body { diff --git a/lib/tools.js b/lib/tools.js index dcbe15a7..49fe14fb 100644 --- a/lib/tools.js +++ b/lib/tools.js @@ -1,5 +1,6 @@ 'use strict'; +const os = require('os'); const punycode = require('punycode'); const libmime = require('libmime'); const consts = require('./consts'); @@ -165,6 +166,11 @@ function getMailboxCounter(db, mailbox, type, done) { function renderEmailTemplate(tags, template) { let result = JSON.parse(JSON.stringify(template)); + let specialTags = { + TIMESTAMP: Date.now(), + HOSTNAME: tags.DOMAIN || os.hostname() + }; + let walk = (node, nodeKey) => { if (!node) { return; @@ -188,6 +194,8 @@ function renderEmailTemplate(tags, template) { node[key] = node[key].replace(/\[([^\]]+)\]/g, (match, tag) => { if (tag in tags) { return isHTML ? he.encode(tags[tag]) : tags[tag]; + } else if (tag in specialTags) { + return isHTML ? he.encode((specialTags[tag] || '').toString()) : specialTags[tag]; } return match; }); @@ -245,7 +253,7 @@ function getEmailTemplates(tags, callback) { entry.message.html = entry.message.html.replace( new RegExp('(["\'])(?:.\\/)?(?:' + name + '.)?' + fname + '(?=["\'])', 'g'), (m, p) => { - attachment.cid = attachment.cid || crypto.randomBytes(8).toString('hex') + '@wildduck.email'; + attachment.cid = attachment.cid || crypto.randomBytes(8).toString('hex') + '-[TIMESTAMP]@[DOMAIN]'; return p + 'cid:' + attachment.cid; } );
- [FNAME], welcome to Wild Duck email service! + [FNAME], welcome to Wild Duck email service!
- If you are seeing this message then it means you have reached the inbox of your new email address [EMAIL]. Be aware though that the service is in a constant change, so this address might disappear during the next database schema update. Don't start using it as your main email address! +
+ +
If you are seeing this message then it means you have reached the inbox of your new email address [EMAIL]. Be aware though that the service is in a constant change, so this address might disappear during the next database schema update. Don't start using it as your main email address!
- This message was generated and inserted to this mailbox from the /emails folder using the default template. + This message was generated and inserted to this mailbox from the /emails folder using the default template. Also note the duck image, it is included in the message as an embedded attachment.