mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
use nodemailer-html-to-text plugin to transform html content to plain text
This commit is contained in:
parent
c94715a128
commit
f483220590
@ -95,6 +95,7 @@
|
||||
"neode": "^0.3.3",
|
||||
"node-fetch": "~2.6.0",
|
||||
"nodemailer": "^6.3.0",
|
||||
"nodemailer-html-to-text": "^3.1.0",
|
||||
"npm-run-all": "~4.1.5",
|
||||
"request": "~2.88.0",
|
||||
"sanitize-html": "~1.20.1",
|
||||
|
||||
@ -1,18 +1,24 @@
|
||||
import CONFIG from '../../config'
|
||||
import nodemailer from 'nodemailer'
|
||||
import { htmlToText } from 'nodemailer-html-to-text'
|
||||
import { resetPasswordMail, wrongAccountMail } from './templates/passwordReset'
|
||||
import { signupTemplate } from './templates/signup'
|
||||
|
||||
let sendMail
|
||||
if (CONFIG.SMTP_HOST && CONFIG.SMTP_PORT) {
|
||||
sendMail = async templateArgs => {
|
||||
await transporter().sendMail({
|
||||
const transport = transporter()
|
||||
transport.use('compile', htmlToText({
|
||||
ignoreImage: true,
|
||||
wordwrap: false,
|
||||
}))
|
||||
await transport.sendMail({
|
||||
from: '"Human Connection" <info@human-connection.org>',
|
||||
...templateArgs,
|
||||
})
|
||||
}
|
||||
} else {
|
||||
sendMail = () => {}
|
||||
sendMail = () => { }
|
||||
if (process.env.NODE_ENV !== 'test') {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('Warning: Email middleware will not try to send mails.')
|
||||
|
||||
@ -78,6 +78,10 @@
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
/* What it does: A work-around for email clients meddling in triggered links. */
|
||||
a[x-apple-data-detectors],
|
||||
/* iOS */
|
||||
@ -199,7 +203,7 @@
|
||||
<!-- Preview Text Spacing Hack : BEGIN -->
|
||||
<div
|
||||
style="display: none; font-size: 1px; line-height: 1px; max-height: 0px; max-width: 0px; opacity: 0; overflow: hidden; mso-hide: all; font-family: sans-serif;">
|
||||
‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌
|
||||
‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ <br>
|
||||
</div>
|
||||
<!-- Preview Text Spacing Hack : END -->
|
||||
|
||||
@ -271,12 +275,15 @@
|
||||
<tr>
|
||||
<td
|
||||
style="padding: 20px; font-family: Lato, sans-serif; font-size: 16px; line-height: 22px; color: #555555;">
|
||||
<p></p>
|
||||
<p style="margin: 0;">Or you can copy this code and paste it in your browser window: <span
|
||||
style="color: #17b53e;">{{{ nonce }}}</span></p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center; color :#17b53e">–––––––––––––––––––––––––––––––––––––––––––––––</td>
|
||||
<td style="text-align: center; color :#17b53e">
|
||||
<p>–––––––––––––––––––––––––––––––––––––––––––––––</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
@ -292,13 +299,15 @@
|
||||
style="padding: 20px; font-family: Lato, sans-serif; font-size: 16px; line-height: 22px; color: #555555;">
|
||||
<p style="margin: 0;">If you didn't sign up for <a href="https://human-connection.org"
|
||||
style="color: #17b53e;">Human Connection</a> we recommend you to check it out!
|
||||
It's an online platform for people to connect and change the world together.</p>
|
||||
It's a social network from people for people who want to connect and change the world together.</p>
|
||||
<p style="margin: 0; margin-top: 10px;">PS: If you ignore this email we will not create an account for
|
||||
you. ;)</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="text-align: center; color :#17b53e">–––––––––––––––––––––––––––––––––––––––––––––––</td>
|
||||
<td style="text-align: center; color :#17b53e">
|
||||
<p>–––––––––––––––––––––––––––––––––––––––––––––––</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
@ -314,7 +323,7 @@
|
||||
style="padding: 20px; font-family: Lato, sans-serif; font-size: 16px; line-height: 22px; color: #555555;">
|
||||
<p style="margin: 0;">Feel free to <a href="{{{ supportUrl }}}" style="color: #17b53e;">contact our
|
||||
support team</a> with any
|
||||
questions you might have.</p>
|
||||
questions you have.</p>
|
||||
<p style="margin: 0; margin-top: 10px;">See you soon on <a href="https://human-connection.org"
|
||||
style="color: #17b53e;">Human Connection</a>!</p>
|
||||
<p style="margin: 0;">– The Human Connection Team</p>
|
||||
|
||||
@ -3,7 +3,6 @@ import fs from 'fs'
|
||||
import path from 'path'
|
||||
import mustache from 'mustache'
|
||||
|
||||
const signupText = fs.readFileSync(path.join(__dirname, './signup.txt'), 'utf-8')
|
||||
const signupHtml = fs.readFileSync(path.join(__dirname, './signup.html'), 'utf-8')
|
||||
|
||||
export const signupTemplate = options => {
|
||||
@ -20,7 +19,6 @@ export const signupTemplate = options => {
|
||||
return {
|
||||
to: email,
|
||||
subject,
|
||||
text: mustache.render(signupText, { actionUrl, nonce, supportUrl }),
|
||||
html: mustache.render(signupHtml, { actionUrl, nonce, supportUrl }),
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,42 +0,0 @@
|
||||
Willkommen bei Human Connection! Klick auf diesen Link, um den
|
||||
Registrierungsprozess abzuschließen und um ein Benutzerkonto zu erstellen!
|
||||
|
||||
{{{actionUrl}}}
|
||||
|
||||
Alternativ kannst du diesen Code auch kopieren und im Browserfenster einfügen:
|
||||
|
||||
{{{nonce}}}
|
||||
|
||||
Bitte ignoriere diese Mail, falls du dich nicht bei Human Connection angemeldet
|
||||
hast. Bei Fragen kontaktiere gerne unseren Support:
|
||||
|
||||
{{{supportUrl}}}
|
||||
|
||||
Danke,
|
||||
Das Human Connection Team
|
||||
|
||||
|
||||
English Version
|
||||
===============
|
||||
|
||||
Welcome to Human Connection! Use this link to complete the registration process
|
||||
and create a user account:
|
||||
|
||||
{{{actionUrl}}}
|
||||
|
||||
You can also copy+paste this verification nonce in your browser window:
|
||||
|
||||
{{{nonce}}}
|
||||
|
||||
If you did not signed up for Human Connection, please ignore this email or
|
||||
contact support if you have questions:
|
||||
|
||||
{{{supportUrl}}}
|
||||
|
||||
Thanks,
|
||||
The Human Connection Team
|
||||
|
||||
Human Connection gemeinnützige GmbH
|
||||
Bahnhofstr. 11
|
||||
73235 Weilheim / Teck
|
||||
Deutschland
|
||||
@ -4293,6 +4293,11 @@ he@0.5.0:
|
||||
resolved "https://registry.yarnpkg.com/he/-/he-0.5.0.tgz#2c05ffaef90b68e860f3fd2b54ef580989277ee2"
|
||||
integrity sha1-LAX/rvkLaOhg8/0rVO9YCYknfuI=
|
||||
|
||||
he@^1.2.0:
|
||||
version "1.2.0"
|
||||
resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f"
|
||||
integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==
|
||||
|
||||
helmet-crossdomain@0.4.0:
|
||||
version "0.4.0"
|
||||
resolved "https://registry.yarnpkg.com/helmet-crossdomain/-/helmet-crossdomain-0.4.0.tgz#5f1fe5a836d0325f1da0a78eaa5fd8429078894e"
|
||||
@ -4365,7 +4370,17 @@ html-encoding-sniffer@^1.0.2:
|
||||
dependencies:
|
||||
whatwg-encoding "^1.0.1"
|
||||
|
||||
htmlparser2@^3.10.0, htmlparser2@^3.9.1:
|
||||
html-to-text@^5.1.1:
|
||||
version "5.1.1"
|
||||
resolved "https://registry.yarnpkg.com/html-to-text/-/html-to-text-5.1.1.tgz#2d89db7bf34bc7bcb7d546b1b228991a16926e87"
|
||||
integrity sha512-Bci6bD/JIfZSvG4s0gW/9mMKwBRoe/1RWLxUME/d6WUSZCdY7T60bssf/jFf7EYXRyqU4P5xdClVqiYU0/ypdA==
|
||||
dependencies:
|
||||
he "^1.2.0"
|
||||
htmlparser2 "^3.10.1"
|
||||
lodash "^4.17.11"
|
||||
minimist "^1.2.0"
|
||||
|
||||
htmlparser2@^3.10.0, htmlparser2@^3.10.1, htmlparser2@^3.9.1:
|
||||
version "3.10.1"
|
||||
resolved "https://registry.yarnpkg.com/htmlparser2/-/htmlparser2-3.10.1.tgz#bd679dc3f59897b6a34bb10749c855bb53a9392f"
|
||||
integrity sha512-IgieNijUMbkDovyoKObU1DUhm1iwNYE/fuifEoEHfd1oZKZDaONBSkal7Y01shxsM49R4XaMdGez3WnF9UfiCQ==
|
||||
@ -6299,6 +6314,13 @@ node-releases@^1.1.25:
|
||||
dependencies:
|
||||
semver "^5.3.0"
|
||||
|
||||
nodemailer-html-to-text@^3.1.0:
|
||||
version "3.1.0"
|
||||
resolved "https://registry.yarnpkg.com/nodemailer-html-to-text/-/nodemailer-html-to-text-3.1.0.tgz#11e4e435eb03e4f3b439aaf294b1bd1377e7f789"
|
||||
integrity sha512-AijyAZgcFb6b53g1oMwdCKyLYQVJzbgZKbs3Bma8zR5hPR1gkajQKGGZbwtuA5JhUqnyC8pjp+tiaS7CkQ8TRg==
|
||||
dependencies:
|
||||
html-to-text "^5.1.1"
|
||||
|
||||
nodemailer@^6.3.0:
|
||||
version "6.3.0"
|
||||
resolved "https://registry.yarnpkg.com/nodemailer/-/nodemailer-6.3.0.tgz#a89b0c62d3937bdcdeecbf55687bd7911b627e12"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user