This puppy aims to make life easier for those that write too many of the same kind of email.
Being part of a growing organization means answering alot of questions about the organization from newcomers. This can be tedious especially when the information is readily available. Many people seek a human connection via internet, so they write an email.
If many people do this the replying human may not have the time to be as informative or as friendly as one wishes. Alas, the newcomer has a sour taste from reading a short, uninformative, hastily written, or a possibly brusk reply.
Everyone likes dogs. Dogs are friendly and attuned to our emotions, habits, and lives. We train them to be helpful. This software is supposed to be like a dog that retrieves the newspaper, barks only at intruders, amiably nuzzles the newcomer, and keeps quiet when it doesn’t know what to do, other than telling the owner that there is trouble. We train it to be helpful. It has the propensity to learn and grow.
Specifically it does the following.
- reads the email account that you have configured
- deduces the language
- analyzes the text according to its language
- extracts information from the analysis
- chooses the appropiate ruleset that you have configured
- if no appropriate ruleset can be found, the email is not answered and the
owner of the email account is notified.
- It only sends one reply for each unknown email. You will not be bombarded with notification emails.
- if an appropriate ruleset can be found, the email is answered and deleted.
The idea of maildog is that you train it for your needs. The following steps detail what this entails.
- Get the software.
pip3 install git+https://github.com/oneyb/maildog # Or: git clone https://github.com/oneyb/maildog cd maildog && python3 setup.py install
NOTE: you will need to install it as root or as your user (pip install –user), in order to have the following scripts in the system path.
- Copy the
tests
directory to where you want it.cp -r /usr/local/lib/python3.5/dist-packages/maildog/maildog/tests/ my_maildog/ # or cp -r maildog/maildog/tests/ my_maildog/
- Inspect and modify the following files according to your taste.
- maildog/tests/example_app.py
- This shows a simple example of what you could set up.
- maildog/tests/reply_data/example.pdf
- You can add any kind of attachment.
- maildog/tests/reply_data/beispiel.pdf
- Ditto.
- maildog/tests/reply_templates/english.txt.j2
- What about a friendly template?
- maildog/tests/reply_templates/german.txt.j2
- Sprechen Sie Deutsch?
- maildog/tests/reply_rulesets/rulesets.csv or
- maildog/tests/reply_rulesets/rulesets.xlsx
- Configure what is sent (which attachment, template, etc.) and when. Don’t change the filename or sheet names from their current configuration.
- maildog/tests/config/maildog.timer
- Why not cron?
- maildog/tests/config/maildog.service
- Sheesh! Two files for a periodically run application?!
- maildog/tests/config/config.py
- What you are storing passwords as plain text? You’d better have that file unreadable and that server well secured.
- maildog/tests/test_render_template.py
- Ah, tests. Good.
- maildog/tests/test_detect_language.py
- Non parle italiano!? Che cazzo!
- maildog/tests/test_email_config.py
- That’s a cute test…
- maildog/tests/test_ruleset.py
- Those named tuples are pretty snazzy, eh?
- maildog/tests/example_app.py
- Install a systemd service for your user.
cp maildog/tests/config/maildog.timer maildog/tests/config/maildog.service $HOME/.config/systemd/user/ systemctl --user enable maildog.timer
- If you have this running on a raspberry pi, you may consider having the service run without you having to login. I mean:
loginctl enable-linger $USER
- Check whether the dog does what you want.
- Enjoy the helpfulness of the new pet.
Given access to an email server, maildog fetches email and chews them into a useful form (Mail).
- Mail:
- has a tokenized (spaCy) form of the email’s subject and body,
- knows the language it was written in (ccld2), and
- based on how you trained the dog (how the rulesets are defined), has chosen a template.
See the definition for more information
I have maildog working for me to reply to certain emails which generally come in two languages. You likely have an interesting case as well. Please contribute if you can. See the open issues for inspiration.