From 297896ac3ed79da564f963c897f39a3c939d8dc3 Mon Sep 17 00:00:00 2001 From: Hugues-Antoine Rabany Date: Wed, 11 Jun 2025 09:53:23 +0200 Subject: [PATCH] Allows MAX_EMAIL_SIZE to run --- README.md | 4 +++- assets/install.sh | 3 +++ assets/webhook.js | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index dfe2689..c2ed97f 100644 --- a/README.md +++ b/README.md @@ -14,9 +14,11 @@ pointing to the server you're running the docker container on. * `URL` is the url to post the parsed email to. The url can contain basic auth credentials. Example: `https://user:password@requestb.in/1bcv6631` +* `__MAX_EMAIL_SIZE__` Allows you to modify the maximum size of an email. The default value is 1000000 for a 1MB email. + * The email is parsed to JSON and posted to the webhook. You can find an [example JSON body here](https://github.com/thingless/mailglove/blob/master/example_post_body.json). Acknowledgments =============== * thanks to https://github.com/catatnight/docker-postfix for initial docker container -* thanks to https://github.com/nodemailer/mailparser for a good email parser +* thanks to https://github.com/nodemailer/mailparser for a good email parser diff --git a/assets/install.sh b/assets/install.sh index f27addc..fd1ba83 100755 --- a/assets/install.sh +++ b/assets/install.sh @@ -51,6 +51,9 @@ postconf -e 'maillog_file = /dev/stdout' # Make the webhook.js use the correct URI sed -i "s/__URL__/${URL//\//\\/}/" /opt/webhook.js +# Make MAX_EMAIL_SIZE. 1MB emails by default +sed -i "s/__MAX_EMAIL_SIZE__/${MAX_EMAIL_SIZE:-1000000}/" /opt/webhook.js + ############# ## Enable TLS ############# diff --git a/assets/webhook.js b/assets/webhook.js index 15b1215..a244626 100644 --- a/assets/webhook.js +++ b/assets/webhook.js @@ -3,7 +3,7 @@ var simpleParser = require('mailparser').simpleParser; var request = require('request'); var WEBHOOK_URL = '__URL__'; //NOTE: can include basic auth in url! -var MAX_SIZE = parseInt(process.env.MAX_EMAIL_SIZE || 1000000); // Allow up to 1MB emails by default +var MAX_SIZE = parseInt(__MAX_EMAIL_SIZE__); function makeRequest(options){ return new Promise((resolve, reject)=>{