Home    |    GitHub Page    |    API    |    FAQ

Joplin-instant-mail instantly converts email into a note or todo item in Joplin

I have developed and actively used joplin-instant-mail for a while. Today I published it on Github:

The script that achieves this has just five lines of code, not counting whitespace, loading a vendor library and some line breaks in the final exec statement which are intended to make it easier to read.

Prerequisites include the Joplin terminal app, an MTA and PHP. As the php script is only 5 lines of code you could quickly rewrite it in the language of your choice if so desired.

This works, so I wanted to share it with everyone for whom it might be useful.

Also I'm sure it can be improved and would be interested in any feedback you might have:

Fore example, consider this statement at the end of the script (multiple lines for readability, but a single exec statement because of the backslashes):
~/.joplin-bin/bin/joplin use Inbox ;
~/.joplin-bin/bin/joplin mktodo '.$safeMessageSubject.' ;
~/.joplin-bin/bin/joplin set '.$safeMessageSubject.' body '.$safeMessageText.';
~/.joplin-bin/bin/joplin sync

Is there any way to pass all the commands to the Joplin terminal app without calling it from the command line four times?

What would be the syntax for that?


You could use Joplin API for this

@roman_r_m What could that look like?

I want to acknowledge: I was inspired and encouraged by Email to Joplin Gateway by @manolitto I was impressed by all the features, including OCR etc., however I was afraid that setting up all the dependencies could be tricky on the host where I wanted to run this.

Also I very much liked the idea of instant conversion (did not want to wait for cron + POP3).

As my host (standard Uberspace 7) already had qmail, node js and php in place, I decided to install Joplin terminal app and try to glue all of it together with a minimum of code. I was happy when I got it done with five lines :slightly_smiling_face:

Here's the doc: https://joplinapp.org/api/references/rest_api/

There was a python package as well, I believe.

There is also a npm package for nodejs

Thank you @roman_r_m @rxliuli !

From the API docs I conclude that creating todo, setting body and parent folder could be done in a single POST request, which is certainly attractive!

Hmm, I'm running the terminal app + current script on a mail server without any display I can access and it works perfectly. If I understood correctly, the clipper service needs to be running for the API to be accessible?
Having a port open is also tricky as I'm using a shared host. Opening ports work, but specific ones may be taken, which makes things more complicated.

When I try to convert
~/.joplin-bin/bin/joplin "use Inbox" ~/.joplin-bin/bin/joplin "mktodo 'foo1'"
~/.joplin-bin/bin/joplin "mktodo 'foo2'" ~/.joplin-bin/bin/joplin "sync"

...into a single call like this ...
$ ~/.joplin-bin/bin/joplin "use Inbox ; mktodo 'foo1' ; mktodo 'foo2' ; 'sync'"

... I get this error message:
No such command: use Inbox ; mktodo 'foo1' ; mktodo 'foo2' ; 'sync'

Is there any trick to chain commands together for the terminal app?