forked from ppfun/pixelplanet
Option to use gmail for mail delivery and format mail as html
This commit is contained in:
parent
958d4a35ec
commit
d056c8111e
|
@ -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
|
||||
|
||||
|
|
|
@ -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}`);
|
||||
|
||||
|
|
|
@ -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({
|
||||
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: `<em>Hello ${name}</em>,<br />\nwelcome to our little community of pixelplacers, to use your account, you have to verify your mail. You can do that <a href="${verifyUrl}">here</a>. Or by copying following url:<br />${verifyUrl}\n<br />\nHave fun and don't hesitate to contact us if you encouter any problems :)<br />\nThanks<br /><br />\n<img alt="" src="https://assets.pixelplanet.fun/tile.png" style="height:64px; width:64px" />`,
|
||||
}, (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: `<em>Hello</em>,<br />\nYou requested to get a new password. You can change your password within the next 30min <a href="${restoreUrl}">here</a>. Or by copying following url:<br />${restoreUrl}\n<br />\nIf you did not request this mail, please just ignore it (the ip that requested this mail was ${ip}).<br />\nThanks<br /><br />\n<img alt="" src="https://assets.pixelplanet.fun/tile.png" style="height:64px; width:64px" />`,
|
||||
}, (err) => {
|
||||
if (err) {
|
||||
logger.error(err & err.stack);
|
||||
|
|
Loading…
Reference in New Issue
Block a user