Postfix - pcre


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Postfix - pcre
# 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

Login or Register to Ask a Question

Previous Thread | Next Thread

5 More Discussions You Might Find Interesting

1. UNIX and Linux Applications

Postfix: Active Directory and postfix alias

I have a mailserver with postfix i want to alias all mail for administrator@domain.fqdn to root@domain.fqdn I have the aliases configured,and i did newliases but doesn't work. How to did this?Postfix is configured for virtual domain on ad server. (2 Replies)
Discussion started by: Linusolaradm1
2 Replies

2. Shell Programming and Scripting

PCRE negative lookahead

I have read many tutorials and cannot get this to work. I need to use pcre (because that is what the library in the software we are using uses) and pcregrep everything except /home from the /etc/fstab pcregrep '(?!/home)' /etc/fstab It returns the entire fstab (This is on a RHEL5... (1 Reply)
Discussion started by: insania
1 Replies

3. UNIX for Dummies Questions & Answers

Please help with Postfix config issue - How to allow remote Exchange server to relay to my postfix

Hi guys One of our clients have a problem with sending email to a certain domain. No matter what we try, the mails just dont get delivered. What I did then, is created a new connector on their Exchange server, pointing all mail sent to their client at "domain1" to relay to our Postfix mail... (0 Replies)
Discussion started by: wbdevilliers
0 Replies

4. Shell Programming and Scripting

PCRE string questions.

What is the string that would satisfy this expression: "^gs{3}$" ? What is an expression that would satisfy all these strings: csafaq.exe, csafbc.exe, asdfcd.exe? Also, To catch these files, : gdnus1862.exe gdnus10.exe gdnus250.exe gdnus2337.exe I am using this regex. :... (2 Replies)
Discussion started by: komputersman
2 Replies

5. IP Networking

postfix - reinject mail to postfix from hold queue directory

hi all. Am using smtpd_recipient_restrictions & check_recipient_access in postfix. The hash file looks like this: emailaddress1 HOLD emailaddress2 HOLD The aim is to place email from these recipients in the hold directory,check them then reinject them back in postfix on some... (0 Replies)
Discussion started by: coolatt
0 Replies
Login or Register to Ask a Question

Featured Tech Videos