On Tue, Jun 09, 2020 at 11:06:57AM +0100, Sam Kuper wrote:
> On Tue, Jun 09, 2020 at 10:36:28AM +0200, Bastian wrote:
>> On 09Jun20 09:51+0200, Kia Niskavaara wrote:
>>> I'm looking for a scriptable email client for linux cli.
>>> Specifically I need to connect it to a Gmail account using IMAP IDLE
>>> so that I will be able to find new emails almost immediately. And
>>> secondly, when new emails arrive, I need a script that automatically
>>> parse the body of every email to look if they match a specific
>>> regular expression - and if they match, then another script should
>>> be executed.
>> 
>> This sounds like you are looking for a fetchmail/procmail solution. I
>> still use those since years, well already decades, in very simple
>> way. 
> 
> Yes :)
> 
> For anyone (e.g. the OP) who might be unfamilier with the terms,
> Fetchmail is an "MRA" ("Mail Retrieval Agent") and Procmail is an "MDA"
> ("Mail Delivery Agent").

That said, Mutt can do quite a bit of what you need.

Within Mutt, you can:

1. use the "limit" functionality to find exactly the emails you are
interested in (e.g. new emails matching some regex);

2. use the "tag" functionality to select all those emails; and finally

3. use the "pipe" functionality to send the tagged emails to your
script, via stdin.

I believe you could also put this functionality into a "macro" in Mutt,
so that you could perform all three steps with a single keystroke.

Good luck!

-- 
A: When it messes up the order in which people normally read text.
Q: When is top-posting a bad thing?

()  ASCII ribbon campaign. Please avoid HTML emails & proprietary
/\  file formats. (Why? See e.g. https://v.gd/jrmGbS ). Thank you.

Reply via email to