diff --git a/README.md b/README.md
index f53b9e76..b9d39d35 100644
--- a/README.md
+++ b/README.md
@@ -89,12 +89,15 @@ Configuration takes place in the environment variables that are defined in ecosy
| USE_XREALIP | see cloudflare section | 1 |
| BACKUP_URL | url of backup server (see Backup) | "http://localhost" |
| BACKUP_DIR | mounted directory of backup server | "/mnt/backup/" |
+| GMAIL_USER | gmail username if used for mails | "ppfun@gmail.com" |
+| GMAIL_PW | gmail password if used for mails | "lolrofls" |
Notes:
- to be able to use USE_PROXYCHECK, you have to have an account on proxycheck.io or getipintel or another checker setup and you might set some proxies in `src/proxies.json` (before building) that get used for making proxycheck requests. Look into `src/isProxy.js` to see how things work, but keep in mind that this isn't neccessarily how pixelplanet.fun uses it.
- Admins are users with 0cd and access to `./admintools` for image-upload and whatever
- You can find out the id of a user by looking into the logs (i.e. `info: {ip} / {id} wants to place 2 in (1701, -8315)`) when he places a pixel or by checking the MySql Users database
+- If you use gmail as mail transport, make sure that less-secure apps are allowed to access it in your settings [here](https://myaccount.google.com/lesssecureapps)
#### Social Media
diff --git a/src/core/config.js b/src/core/config.js
index 24053375..5356e7a0 100644
--- a/src/core/config.js
+++ b/src/core/config.js
@@ -11,6 +11,9 @@ if (process.env.BROWSER) {
export const PORT = process.env.PORT || 80;
+export const GMAIL_USER = process.env.GMAIL_USER || null;
+export const GMAIL_PW = process.env.GMAIL_PW || null;
+
const TILE_FOLDER_REL = process.env.TILE_FOLDER || 'tiles';
export const TILE_FOLDER = path.join(__dirname, `./${TILE_FOLDER_REL}`);
diff --git a/src/core/mail.js b/src/core/mail.js
index f394269e..5d9753c4 100644
--- a/src/core/mail.js
+++ b/src/core/mail.js
@@ -9,6 +9,7 @@ import nodemailer from 'nodemailer';
import logger from './logger';
import { HOUR, MINUTE } from './constants';
import { DailyCron, HourlyCron } from '../utils/cron';
+import { GMAIL_USER, GMAIL_PW } from './config';
import RegUser from '../data/models/RegUser';
@@ -17,11 +18,22 @@ import RegUser from '../data/models/RegUser';
* define mail transport
* using unix command sendmail
*/
-const transporter = nodemailer.createTransport({
- sendmail: true,
- newline: 'unix',
- path: '/usr/sbin/sendmail',
-});
+const transporter = (GMAIL_USER && GMAIL_PW)
+ ? nodemailer.createTransport({
+ service: 'gmail',
+ auth: {
+ user: GMAIL_USER,
+ pass: GMAIL_PW,
+ },
+ })
+ : nodemailer.createTransport({
+ sendmail: true,
+ newline: 'unix',
+ path: '/usr/sbin/sendmail',
+ });
+const from = (GMAIL_USER && GMAIL_PW)
+ ? GMAIL_USER
+ : 'donotreply@pixelplanet.fun';
// TODO make code expire
@@ -54,16 +66,18 @@ class MailProvider {
const code = this.setCode(to);
const verifyUrl = `${host}/api/auth/verify?token=${code}`;
transporter.sendMail({
- from: 'donotreply@pixelplanet.fun',
+ from,
to,
replyTo: 'donotreply@pixelplanet.fun',
// eslint-disable-next-line max-len
subject: `Welcome ${name} to PixelPlanet, plese verify your mail`,
// eslint-disable-next-line max-len
- text: `Hello,\nwelcome to our little community of pixelplacers, to use your account, you have to verify your mail. You can do that here:\n ${verifyUrl} \nHave fun and don't hesitate to contact us if you encouter any problems :)\nThanks`,
+ // text: `Hello,\nwelcome to our little community of pixelplacers, to use your account, you have to verify your mail. You can do that here:\n ${verifyUrl} \nHave fun and don't hesitate to contact us if you encouter any problems :)\nThanks`,
+ // eslint-disable-next-line max-len
+ html: `Hello ${name},
\nwelcome to our little community of pixelplacers, to use your account, you have to verify your mail. You can do that here. Or by copying following url:
${verifyUrl}\n
\nHave fun and don't hesitate to contact us if you encouter any problems :)
\nThanks
\n
`,
}, (err) => {
if (err) {
- logger.error(err & err.stack);
+ logger.error(err);
}
});
return null;
@@ -101,13 +115,14 @@ class MailProvider {
const code = this.setCode(to);
const restoreUrl = `${host}/reset_password?token=${code}`;
transporter.sendMail({
- from: 'donotreply@pixelplanet.fun',
+ from,
to,
replyTo: 'donotreply@pixelplanet.fun',
- // eslint-disable-next-line max-len
subject: 'You forgot your password for PixelPlanet? Get a new one here',
// eslint-disable-next-line max-len
- text: `Hello,\nYou requested to get a new password. You can change your password within the next 30min here:\n ${restoreUrl} \nHave fun and don't hesitate to contact us if you encouter any problems :)\nIf you did not request this mail, please just ignore it (the ip that requested this mail was ${ip}).\nThanks`,
+ // text: `Hello,\nYou requested to get a new password. You can change your password within the next 30min here:\n ${restoreUrl} \nHave fun and don't hesitate to contact us if you encouter any problems :)\nIf you did not request this mail, please just ignore it (the ip that requested this mail was ${ip}).\nThanks`,
+ // eslint-disable-next-line max-len
+ html: `Hello,
\nYou requested to get a new password. You can change your password within the next 30min here. Or by copying following url:
${restoreUrl}\n
\nIf you did not request this mail, please just ignore it (the ip that requested this mail was ${ip}).
\nThanks
\n
`,
}, (err) => {
if (err) {
logger.error(err & err.stack);