- Simple email reply automation with python
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
- [[file:maildog/tests/config/config.py][maildog/tests/config/config.py]]
- deduces the language
- analyzes the text according to its language
- extracts information from the analysis
- [[file:maildog/init.py][maildog/init.py]]
- chooses the appropiate ruleset that you have configured
- [[file:maildog/rulesets.py][maildog/rulesets.py]]
- 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.
-
- Get maildog working for you
The idea of maildog is that you train it for your needs. The following steps
detail what this entails.
** Install and configure it
-
Get the software.
+BEGIN_SRC shell
pip3 install git+https://github.com/oneyb/maildog
Or:
git clone https://github.com/oneyb/maildog
cd maildog && python3 setup.py install
+END_SRC
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.
+BEGIN_SRC shell
cp -r /usr/local/lib/python3.5/dist-packages/maildog/maildog/tests/ my_maildog/
or
cp -r maildog/maildog/tests/ my_maildog/
+END_SRC
-
Inspect and modify the following files according to your taste.
- [[file:maildog/tests/example_app.py][maildog/tests/example_app.py]]
- This shows a simple example of what you could set up.
- [[file:maildog/tests/reply_data/example.pdf][maildog/tests/reply_data/example.pdf]]
- You can add any kind of attachment.
- [[file:maildog/tests/reply_data/beispiel.pdf][maildog/tests/reply_data/beispiel.pdf]]
- [[file:maildog/tests/reply_templates/english.txt.j2][maildog/tests/reply_templates/english.txt.j2]]
- What about a friendly template?
- [[file:maildog/tests/reply_templates/german.txt.j2][maildog/tests/reply_templates/german.txt.j2]]
- [[file:maildog/tests/reply_rulesets/rulesets.csv][maildog/tests/reply_rulesets/rulesets.csv]] or
- [[file:maildog/tests/reply_rulesets/rulesets.csv][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.
- [[file:maildog/tests/config/maildog.timer][maildog/tests/config/maildog.timer]]
- [[file:maildog/tests/config/maildog.service][maildog/tests/config/maildog.service]]
- Sheesh! Two files for a periodically run application?!
- [[file:maildog/tests/config/config.py][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.
- [[file:maildog/tests/test_render_template.py][maildog/tests/test_render_template.py]]
- [[file:maildog/tests/test_detect_language.py][maildog/tests/test_detect_language.py]]
- Non parle italiano!? Che cazzo!
- [[file:maildog/tests/test_email_config.py][maildog/tests/test_email_config.py]]
- [[file:maildog/tests/test_ruleset.py][maildog/tests/test_ruleset.py]]
- Those named tuples are pretty snazzy, eh?
-
Install a systemd service for your user.
+BEGIN_SRC shell
cp maildog/tests/config/maildog.timer maildog/tests/config/maildog.service $HOME/.config/systemd/user/
systemctl --user enable maildog.timer
+END_SRC
-
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).
- Contributions are welcome
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.