Postfix - pcre

Tags
advanced, pcre, postfix, solved

 
Thread Tools Search this Thread
# 1  
Old 08-24-2018
Postfix - pcre

Hello.
I need to test valid sender address.
I have created a rule in main.cf :
Code:
smtpd_sender_login_maps = pcre:/etc/postfix/sender_login_maps.pcre
smtpd_sender_restrictions =
    reject_non_fqdn_sender,
    reject_unknown_sender_domain,
    reject_sender_login_mismatch

THe file '/etc/postfix/sender_login_maps.pcre' contain :
Code:
/^[a-zA-Z0-9.-]+@troll-hathor.nwk$/   ${1}

When I try the regex in some internet site (https://www.regextester.com/19), I got a null result for a bad string
Code:
first.name@mon_domain.com@mon_domain.com

which return
Code:
NULL

and I got the initial string for a good string
Code:
first.name@mon_domain.com

which return :
Code:
first.name@mon_domain.com

When testing the rule with postfix, a bad string
Code:
sudo postmap -f -q first.name@mon_domain.com@mon_domain.com pcre:/etc/postfix/sender_login_maps.pcre

return :
Code:
first.name@mon_domain.com

A good string :
Code:
sudo postmap -f -q first.name@mon_domain.com pcre:/etc/postfix/sender_login_maps.pcre

return :
Code:
first.name

I am expecting a null string if the sender must be rejected.
It seems to be a rewrite functionality.


I want the mail rejected (not send if the sender is rejected)



Any help is welcome.
# 2  
Old 08-26-2018
Quote:
Originally Posted by jcdole
THe file '/etc/postfix/sender_login_maps.pcre' contain :
Code:
/^[a-zA-Z0-9.-]+@troll-hathor.nwk$/   ${1}

Changing code to this works :

Code:
/^[a-zA-Z0-9.-]+@troll-hathor.nwk$/   ${1}@troll-hathor.nwk


|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Convert posix regex to pcre (perl) urello Shell Programming and Scripting 1 06-19-2014 07:45 PM
Postfix: Active Directory and postfix alias Linusolaradm1 UNIX and Linux Applications 2 03-26-2013 08:40 PM
Gettin problem with PCRE on solaris 10 server. muraliinfy04 Solaris 0 02-28-2012 05:13 AM
PCRE negative lookahead insania Shell Programming and Scripting 1 01-10-2011 04:33 PM
Please help with Postfix config issue - How to allow remote Exchange server to relay to my postfix wbdevilliers UNIX for Dummies Questions & Answers 0 02-26-2010 06:28 AM
PCRE string questions. komputersman Shell Programming and Scripting 2 10-19-2009 05:25 PM
postfix - reinject mail to postfix from hold queue directory coolatt IP Networking 0 07-23-2009 04:08 PM