On Sat, Oct 14, 2023 at 05:00:41PM +0200, Sagar Acharya wrote: > Are there such tutorials in Lua? > > filter keep proc-exec /path/to/script.lua > > With above configuration, how does the script run? How is mail input given to > it? At what step can I get size of attachments without downloading them. > > if sizeof_attach(mail)>0 > return 0; > > Does it work like cgi, i.e. standard output?
It is similar in principle to cgi, in as much as your script does all of it's I/O through standard input and standard output. But there are no 'high level' functions to, for example, get the number of attachments or size of attachments. Instead you need to parse the actual raw mail body yourself to get this information. Also, the filter does not just receive the mail body directly on standard input, there is an API that you need to use. The best place to start would be to read the manual page smtpd-filters. This explains the filters API. Then try to a get a simple filter working before you start on a more complicated project.
