Wednesday, August 28, 2024

I reactivated ticket #4381 (Uploading photos or other media files via email (postfix)).

I am plying with the /home/photos/bin/photos.py script on SR. It is called because the /etc/aliases defines an alias:

photos:             "|/home/photos/bin/photos.py"

That script is increasing in complexity and I should definitively publish it somewhere in a git repository rather than editing it with nano in a terminal.

Should I publish it as a django-admin command? No, because we don’t want to start the whole Django machine for every incoming email. Let it be an independent little command-line tool. But how to name it? Maybe mail2mime?

While meditating on this I stumbled into a question on SO postfix - access to incoming mail info inside of python script where the author uses a file .procmailrc and a tool ripmime. Am I reinventing the wheel?

Seems that ripmime is not enough for our use case. We want a few features that are quite specific to Lino:

  • The tool should read a list of allowed recipients from a plain text file and refuse any incoming mail from other recipients.

  • The plain text file would be generated by the Lino site and give the Lino user name for every allowed recipient email address.

  • The tool should read the subject and the body of the email, and pass them to an application-specific Lino command.

A new mail2json script would write a json file containing subject, body, sender, timestamp, and all attachments to a directory. And the Lino site runs a background task that watches this directory for new json files. And each new json file will create an uploads.Upload row for each attachment, and one comments.Comment for each json file.

The story continues here: Thursday, August 29, 2024.