mirror of
https://blitiri.com.ar/repos/chasquid
synced 2026-01-27 20:45:56 +00:00
smtpsrv: Implement a post-DATA hook
This patch implements a post-DATA hook, which is run after receiving the data but before sending a reply. It can be used to implement content filtering when receiving email, for example for passing the email through an anti-spam or an anti-virus.
This commit is contained in:
5
test/t-10-hooks/config/hooks/post-data.bad1
Executable file
5
test/t-10-hooks/config/hooks/post-data.bad1
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo $0 > ../.data/post-data.out
|
||||
echo "This is not a header"
|
||||
|
||||
8
test/t-10-hooks/config/hooks/post-data.bad2
Executable file
8
test/t-10-hooks/config/hooks/post-data.bad2
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo $0 > ../.data/post-data.out
|
||||
|
||||
echo "X-Post-DATA: This starts like a header"
|
||||
echo
|
||||
echo "But then is not"
|
||||
|
||||
7
test/t-10-hooks/config/hooks/post-data.bad3
Executable file
7
test/t-10-hooks/config/hooks/post-data.bad3
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo $0 > ../.data/post-data.out
|
||||
|
||||
# Just a newline is quite problematic, as it would break the headers.
|
||||
echo
|
||||
|
||||
5
test/t-10-hooks/config/hooks/post-data.bad4
Executable file
5
test/t-10-hooks/config/hooks/post-data.bad4
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo $0 > ../.data/post-data.out
|
||||
|
||||
echo -n "X-Post-DATA: valid header with no newline at the end"
|
||||
14
test/t-10-hooks/config/hooks/post-data.good
Executable file
14
test/t-10-hooks/config/hooks/post-data.good
Executable file
@@ -0,0 +1,14 @@
|
||||
#!/bin/bash
|
||||
|
||||
env > ../.data/post-data.out
|
||||
echo >> ../.data/post-data.out
|
||||
|
||||
cat >> ../.data/post-data.out
|
||||
|
||||
if [ "$RCPT_TO" == "blockme@testserver" ]; then
|
||||
echo "¡No pasarán!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "X-Post-Data: success"
|
||||
|
||||
Reference in New Issue
Block a user