Thank you for your kind help. I have now solved it using getmail and procmail. I've set up getmail as a deamon and it's using IMAP IDLE. Procmail has a simple filter that match sender and sends to external script. I'm also using mutt when testing procmail filters.
Kia On Tue, Jun 9, 2020 at 1:12 PM Dave Wood <d...@tty1.uk> wrote: > On 09/06/20 09:51, > Kia Niskavaara <kia.niskava...@gmail.com> put forth the proposition: > > Hi all > > > > 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. > > > > Is this possible with Mutt? Can someone point me in the right direction? > > I've looked at the FAQ/Google, but couldn't find anything about this > > scenario. > > > > Thank you > > > > Kia > > Procmail is very good for filtering email, also in combination with > `formail' to filter out portions of headers. > > Procmail can search the headers and/or body for regexps, and then run > other applications, scripts, or forward emails depending on the > results. > > I tend to use `getmail' running once a minute via a cron job, but I > believe it can operate in an idle mode too. > > -- > Dave >