diff --git a/backend/package.json b/backend/package.json index fecfe3441..201d1da37 100644 --- a/backend/package.json +++ b/backend/package.json @@ -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", diff --git a/backend/src/middleware/email/emailMiddleware.js b/backend/src/middleware/email/emailMiddleware.js index 809ca4072..8ce6973e0 100644 --- a/backend/src/middleware/email/emailMiddleware.js +++ b/backend/src/middleware/email/emailMiddleware.js @@ -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" ', ...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.') diff --git a/backend/src/middleware/email/templates/signup.html b/backend/src/middleware/email/templates/signup.html index 189e5f186..fd286a553 100644 --- a/backend/src/middleware/email/templates/signup.html +++ b/backend/src/middleware/email/templates/signup.html @@ -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 @@
- ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌  + ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ 
@@ -271,12 +275,15 @@ +

Or you can copy this code and paste it in your browser window: {{{ nonce }}}

- ––––––––––––––––––––––––––––––––––––––––––––––– + +

–––––––––––––––––––––––––––––––––––––––––––––––

+ @@ -292,13 +299,15 @@ style="padding: 20px; font-family: Lato, sans-serif; font-size: 16px; line-height: 22px; color: #555555;">

If you didn't sign up for Human Connection we recommend you to check it out! - It's an online platform for people to connect and change the world together.

+ It's a social network from people for people who want to connect and change the world together.

PS: If you ignore this email we will not create an account for you. ;)

- ––––––––––––––––––––––––––––––––––––––––––––––– + +

–––––––––––––––––––––––––––––––––––––––––––––––

+ @@ -314,7 +323,7 @@ style="padding: 20px; font-family: Lato, sans-serif; font-size: 16px; line-height: 22px; color: #555555;">

Feel free to contact our support team with any - questions you might have.

+ questions you have.

See you soon on Human Connection!

– The Human Connection Team

diff --git a/backend/src/middleware/email/templates/signup.js b/backend/src/middleware/email/templates/signup.js index 2f77d0efa..a6abdf6f2 100644 --- a/backend/src/middleware/email/templates/signup.js +++ b/backend/src/middleware/email/templates/signup.js @@ -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 }), } } diff --git a/backend/src/middleware/email/templates/signup.txt b/backend/src/middleware/email/templates/signup.txt deleted file mode 100644 index c3e2ba8c6..000000000 --- a/backend/src/middleware/email/templates/signup.txt +++ /dev/null @@ -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 diff --git a/backend/yarn.lock b/backend/yarn.lock index d59891c1c..73b67e5ef 100644 --- a/backend/yarn.lock +++ b/backend/yarn.lock @@ -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"