Re: Example of smtpd-filters

2023-10-21 Thread Omar Polo
On 2023/10/20 21:52:41 +0200, Sagar Acharya  wrote:
> I'm simply unable to start.
> 
> I have to know where to get the mail from, format of text, which process to 
> give the return to, in what format, i.e. are there any standard return values 
> for accept or reject mail.

I'd like to stress the point that a key difference of OpenSMTPD'
filters is that they DO NOT EXIT.  A filter is just a program (or a
script) that is executed by smtpd at start and never exits.  If a
filter quits, it's a non-recoverable failure and smtpd dies too.

The filter and smtpd talk via a simple protocol: smtpd writes lines to
the filter standard input and the filter writes its responses to the
standard output.

Tassilo already shared some very sample code to get you started, for
the rest you can refer to smtpd-filters[0] which describes the
protocol.  Feel free (of course!) to ask for clarification for any
aspect not clearly covered in the manual page.


Thanks,

Omar Polo


[0]: https://man.openbsd.org/smtpd-filters.7



Re: Example of smtpd-filters

2023-10-20 Thread Tassilo Philipp
You basically write a script that processes incoming lines on stdin, and 
writes back to stdout. The protocol is described in smtpd-filters(7).


This basic idea in lua would be something like:

for line in io.lines() do
if line == 'in' then
io.write('out')
end
end

Now handle the lines you want to handle, and respond to them how it's 
described in smtpd-filters(7).



On Fri, Oct 20, 2023 at 09:52:41PM +0200, Sagar Acharya wrote:

I'm simply unable to start.

I have to know where to get the mail from, format of text, which 
process to give the return to, in what format, i.e. are there any 
standard return values for accept or reject mail.

Thanking you
Sagar Acharya
https://humaaraartha.in/selfdost/selfdost.html



20 Oct 2023, 23:47 by tphil...@potion-studios.com:


Post your script that you got so far, explain where you get stuck/confused, and 
someone will probably be happy to help.


On Fri, Oct 20, 2023 at 02:05:13PM +0200, Sagar Acharya wrote:


Can you please help me with a sample script for accepting or rejecting mail in 
lua.

Say there is myfilter.lua within /etc/smtpd/

Can one please help with a sample whose pseudocode goes like

fetch(mail)if mailbody contains foo, reject,
else if mailbody contains bar, accept.

Such a sample script would help very much to support users write their own custom filters. Thanking you 
Sagar Acharya

https://humaaraartha.in/selfdost/selfdost.html







Re: Example of smtpd-filters

2023-10-20 Thread Sagar Acharya
I'm simply unable to start.

I have to know where to get the mail from, format of text, which process to 
give the return to, in what format, i.e. are there any standard return values 
for accept or reject mail.
Thanking you
Sagar Acharya
https://humaaraartha.in/selfdost/selfdost.html



20 Oct 2023, 23:47 by tphil...@potion-studios.com:

> Post your script that you got so far, explain where you get stuck/confused, 
> and someone will probably be happy to help.
>
>
> On Fri, Oct 20, 2023 at 02:05:13PM +0200, Sagar Acharya wrote:
>
>> Can you please help me with a sample script for accepting or rejecting mail 
>> in lua.
>>
>> Say there is myfilter.lua within /etc/smtpd/
>>
>> Can one please help with a sample whose pseudocode goes like
>>
>> fetch(mail)if mailbody contains foo, reject,
>> else if mailbody contains bar, accept.
>>
>> Such a sample script would help very much to support users write their own 
>> custom filters. Thanking you
>> Sagar Acharya
>> https://humaaraartha.in/selfdost/selfdost.html
>>



Re: Example of smtpd-filters

2023-10-20 Thread Tassilo Philipp
Post your script that you got so far, explain where you get 
stuck/confused, and someone will probably be happy to help.



On Fri, Oct 20, 2023 at 02:05:13PM +0200, Sagar Acharya wrote:

Can you please help me with a sample script for accepting or rejecting mail in 
lua.

Say there is myfilter.lua within /etc/smtpd/

Can one please help with a sample whose pseudocode goes like

fetch(mail)if mailbody contains foo, reject,
else if mailbody contains bar, accept.

Such a sample script would help very much to support users write their own custom filters. 
Thanking you

Sagar Acharya
https://humaaraartha.in/selfdost/selfdost.html