On Wed, 15 Feb 2017 17:13:31 +0700
Konstantin Shalygin <k0...@k0ste.ru> wrote:
> Read all about Extprograms, but have a question.
> Use case:
> Every day we have couple messages with attachment (from one sender,
> this is one-way communication). This attachment is uploads to
> ownCloud. By hand... need some automation.
> As I see, pipe cat execute scripts with text data USER/FROM/SUBJECT -
> and I think with variables it can be any text data, how about
> How I see this: script executes and as arg receives from sieve
> attachment file, or message file and we can parse it for attachment.
> When we have attachment - upload to ownCloud via RESTapi and purge
> Found some realization for encrypt messages
> but for me more easy just connect to IMAP and do what I want (but I
> love sieve).
Do you really need Sieve for this?
IMO such things are best handled in the SMTP server:
1) Set up an alias for the mail address receiving these mails.
2) Make that alias expand both to its real final destination
(an address, mails to which would be delivered to the IMAP
folder as before) and to a special "program" entry which looks
like "| /path/to/the/external/program".
See `man aliases`  for more info.
The program is supposed to receive the mail message to its standard
input stream and do whatever it wishes with them. For instance, this
could be a shell script calling something like `ripmime`  on the
input, saving the attachments and then calling into whatever would
Note that if the program completed its task OK, it should return with
the zero result code. Otherwise it's advised to use one of result
codes defined by Sendmail, which are described in  and whose exact
numeric values could be googled (for instance, see ). If your
program return a "known" exit code on error, you'll get better
diagnostics reported for that failure by your SMTP server.