joplin-mail-gateway
joplin-mail-gateway copied to clipboard
Simple (bash-based) mail gateway for the open source note taking and to-do application Joplin
joplin-mail-gateway
Simple (bash-based) mail gateway for the open source note taking and to-do application Joplin.
Rationale
This tool provides a solution for emailing content directly into your Joplin notes.
You may send or forward an email to a dedicated email address. This email is then automatically delivered to your personal Joplin notes. Attachments (PDFs, Images, ...) will automatically be included in the note. In addition text is automatically scanned from images via OCR. This extracted text is added at the bottom of the note so that it is easily searchable in Joplin.
Features
- automatically fetch mails from a certain mail account and add all new mails as Joplin notes
- automatically add mail attachments
- provide tags via mail subject (with #-syntax)
- choose notebook via mail subject (with @-syntax)
- automatically run OCR on images and add text to bottom of note
- automatically add png thumbnails for PDF attachments
- automatically add PDF text part to bottom of note
Prerequisites
-
Joplin terminal application installed and configured
see https://joplin.cozic.net/
Tested with
joplin 1.0.119 (prod) -
pdftoppm and pdftotext must be installed
sudo apt update sudo apt install poppler-utilsTested with
pdftoppm 3.03andpdftotext 3.03 -
tesseract must be installed
sudo apt update sudo apt-get install tesseract-ocrAnd for German training files:
sudo apt-get install tesseract-ocr-deuTested with
tesseract 3.04.01 -
getmail must be installed
sudo apt-get update sudo apt-get install getmail4Tested with
getmail_fetch 4.48.0 -
ripmime must be installed
sudo apt-get update sudo apt install ripmimeTested with
ripmime v1.4.0.9 -
python 3 must be installed
sudo apt-get update sudo apt install python3Tested with
python3 3.5.2.Note: If you are running Ubuntu 20.04.1 LTS, make sure to set Python3 as the default interpreter:
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 10
Install
-
Clone from github
git clone https://github.com/manolitto/joplin-mail-gateway.git -
Create a mail directory for incoming mails with following structure:
mkdir -p ~/joplin-mailbox/new mkdir -p ~/joplin-mailbox/cur mkdir -p ~/joplin-mailbox/tmp -
Create a log directory
sudo mkdir /var/log/fetch-joplin-mails sudo chown $USER /var/log/fetch-joplin-mails -
Create a new mail account at your preferred email provider that supports POP3
-
Create the configuration file
cp config-sample.sh config.sh chmod 700 config.sh -
Change default configuration by editing
config.shreadonly POP3_USER="your-email-user@your-provider" readonly POP3_PW="your-super-secret-pop3-pw" readonly POP3_HOST="pop.gmail.com" readonly POP3_PORT=995 readonly DEFAULT_TITLE_PREFIX="Neue Notiz" readonly DEFAULT_NOTEBOOK="Import" -
Test your configuration
./fetch-joplin-mails.sh -
Add cron job
crontab -eAdd the following line:
*/5 * * * * ~/joplin-mail-gateway/fetch-joplin-mails.sh >>/var/log/fetch-joplin-mails/fetch.log 2>&1
Running from a docker container
The gateway can be run from a docker container. The included Dockerfile does everything from installing joplin to fetching emails
To setup the docker container :
-
prepare the mail-gateway by editing the
config.shfile as described above -
edit the
joplin-config.jsonfile with your Joplin sync settings. Template files are availables. Simple remove the.templateextension -
build the container by running
docker build . -t joplin_gateway -
run the container
docker run -d joplin_gateway