[Sieve] Is the way to run external script to get attachment?
Konstantin Khomoutov
flatworm at users.sourceforge.net
Thu Feb 16 09:19:00 UTC 2017
On Wed, 15 Feb 2017 17:13:31 +0700
Konstantin Shalygin <k0ste at 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
> attachment?
>
> 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
> message.
>
> Found some realization for encrypt messages
> https://github.com/EtiennePerot/gpgit/blob/master/encmaildir.sh
> 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` [4] 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` [1] on the
input, saving the attachments and then calling into whatever would
upload them.
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 [2] and whose exact
numeric values could be googled (for instance, see [3]). If your
program return a "known" exit code on error, you'll get better
diagnostics reported for that failure by your SMTP server.
1. http://www.pldaniels.com/ripmime/
2. http://docstore.mik.ua/orelly/networking/sendmail/ch36_05.htm
3. https://gist.github.com/bojanrajkovic/831993
4. http://www.postfix.org/aliases.5.html
More information about the dovecot
mailing list