Hermann_Amon_23
Nimbostratus
Dec 07, 2017SMTP domain Whitelist Allow SMTP request based on MAIL FROM on serverside
Hello iRule experts,
I am an irule beginner and I need some help.I have a datagroupe that contains more than 200 domain . I need route mail based on the domain found in the FROM header . My irule must verify if this domain has been properly Whitelisted by checking the datagroupe . My Irule Work when I'm using SMTP in cleartext without starttls activated on smtps profil . But with SMTP STARTTLS activated it's not work .So I'm want to check the mail from on Serverside because it using SMTP without Starttls .
CLIENT-----:Port25(allow Starttls)F5--->SMTP(ClearText):Port25-->SERVER
Here is my Irule that check MAIL FROM on CLIENT SIDE : Only Work if I use SMTP without Starttls configured on SMTPS profile
when CLIENT_ACCEPTED {
set cto ""
set cdata ""
log local0. "Connexion de [IP::remote_addr]"
LB::connect
TCP::collect
set hsl [HSL::open -proto UDP -pool splunk.lab.local]
set client_ip [IP::client_addr]
}
when CLIENT_DATA {
log local0. "CLIENT_DATA"
set cdata [TCP::payload]
log local0. "cdata : $cdata"
set hsl [HSL::open -proto UDP -pool splunk.lab.local]
if { [string match -nocase "MAIL FROM:*" $cdata] } {
log local0. "domaine : $cdata"
set fromaddr [regsub -all \[\\r\\n\\s\] $cdata ""]
log local0. "domaine : $fromaddr"
set fromaddr [findstr $fromaddr ":" 1]
log local0. "domaine : $fromaddr"
set fromdomain [findstr $fromaddr "@" 1]
log local0. "domaine : $fromdomain"
if { [ class match [string tolower $fromdomain] contains "MailAddrList2" ] } {
TCP::payload replace 0 0 $cto
pool /Common/SMTP_POOL
log local0. "Email Accept based on the recipient email address"
log local0.info "domaine, $fromdomain, accepted , real client ip is : $client_ip"
HSL::send $hsl "<190> domaine, $fromdomain , accepted, real client ip is : $client_ip \n"
HSL::send $cdata "<190>domaine, $fromdomain , accepted"
} else {
reject
log local0. "Domain not allowed please contact your administrator "
HSL::send $hsl "<190> domaine, $fromdomain , not accepted, real client ip is : $client_ip \n"
}
}
TCP::release
TCP::collect
}
when SERVER_CONNECTED {
log local0. "Connexion au serveur"
TCP::collect
}
when SERVER_DATA {
log local0. "sdata : [TCP::payload]"
TCP::release
`text`
TCP::collect
}
Many thanks in advance
Hermann