paperless-mailhook
Collect incoming emails to Paperless-ng.
Instead of relying on a dedicated email account, it uses webhooks from email
providers such as SendGrid. PRs welcome to support other providers.
Behavior
- Check if incoming email was from allowed email address.
- Check if incoming email was addressed to expected email address, if enabled.
- Check if incoming email has attachments.
- Check if attachment is
.eml file.
- If it is, start at step 3 using contents of attached email.
- If not, upload to Paperless with attachment filename.
- If no attachments, convert email to PDF if Gotenberg is enabled, using subject as filename.
Configuration
| Env Name |
Description |
MAILHOOK_PAPERLESSENDPOINT |
Paperless-ng endpoint, including scheme |
MAILHOOK_PAPERLESSAPIKEY |
Paperless-ng API key |
MAILHOOK_GOTENBERGENDPOINT |
Optional, Gotenberg endpoint, see behavior for more |
MAILHOOK_ALLOWEDEMAILS |
Comma separated list of email addresses allowed to upload documents |
MAILHOOK_TOADDRESS |
Optional, require incoming emails to be addressed to this email address |
MAILHOOK_HTTPHOST |
Optional, host to listen for requests on, defaults to 127.0.0.1:5000 |
MAILHOOK_DEBUG |
Optional, set to true for more verbose logging |
SendGrid
Currently, only SendGrid is supported for incoming email webhooks.
Inbound parse should be set to the /sendgrid endpoint on the domain where this
service is available. SendGrid must be set to send the raw email.
Docker
You can run this using Docker. An image is published at
ghcr.io/syfaro/paperless-mailhook.
docker run -p 5000:5000 \
-e MAILHOOK_PAPERLESSENDPOINT=http://paperless:8000 \
-e MAILHOOK_PAPERLESSAPIKEY=abc123 \
-e MAILHOOK_GOTENBERGENDPOINT=http://gotenberg:3000 \
-e MAILHOOK_ALLOWEDEMAILS=syfaro@huefox.com \
ghcr.io/syfaro/paperless-mailhook:latest
docker-compose
services:
paperless-mailhook:
image: ghcr.io/syfaro/paperless-mailhook:latest
ports:
- "5000:5000"
environment:
MAILHOOK_PAPERLESSENDPOINT: http://paperless:8000
MAILHOOK_PAPERLESSAPIKEY: abc123
MAILHOOK_GOTENBERGENDPOINT: http://gotenberg:3000
MAILHOOK_ALLOWEDEMAILS: syfaro@huefox.com