Hello,
For a few years I have been using mu4e-based email setup to run
per-message actions from Emacs on emails with a single keystroke.
Now I have extracted that framework from my dotfiles to a separate
standalone package:
https://github.com/laurynas-biveinis/mu4e-autotask/
The way it works is the following. You define a list of email
matching rules, based on exact and regex matches on senders and
subjects:
(setq mu4e-autotask-rules
'((:sender-exact "
notifi...@github.com"
:subject-match "^.* Run failed.*$"
:action-fn my-handle-github-run-failed)
(:sender-exact "
nor...@example.com"
:action-fn my-open-example-attachments)))
and for each rule, you declare an Elisp handler function, i.e.
(defun my-open-example-attachments (_msg)
"Open every PDF attachment of the current message."
(mu4e-autotask-open-all-attachments ".pdf"))
Now, when in the message view, press a e (invoking mu4e view
action "Execute automation" installed by the package) and it runs
(the list of rules is checked for the current message and its
handler runs in the case of a match).
The package provides a small library of handler building blocks
(open attachments with specified file extension, save all jpeg
attachments to disk, etc).
Some of the actions might involve sending new emails, and for that
the package provides a templated email sending library too:
(defconst my-invoice-email
(make-mu4e-autotask-email-template
:context "work-gmail"
:to "
accou...@example.com"
:subject "Invoice"
:body "Please find the invoice attached.\n"))
(mu4e-autotask-send-email my-invoice-email
'("/path/to/invoice.pdf")
(lambda () (message "Invoice sent")))
This part is usable outside the rule handlers too.
For the full list of features and installation instructions check
https://github.com/laurynas-biveinis/mu4e-autotask/blob/main/README.org
Any feedback is welcome.