Postfix - pcre


Login or Register to Reply

 
Thread Tools Search this Thread
# 1  
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  
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 Reply

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

More UNIX and Linux Forum Topics You Might Find Helpful
Postfix: Active Directory and postfix alias
Linusolaradm1
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.... UNIX and Linux Applications
2
UNIX and Linux Applications
PCRE negative lookahead
insania
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...... Shell Programming and Scripting
1
Shell Programming and Scripting
Please help with Postfix config issue - How to allow remote Exchange server to relay to my postfix
wbdevilliers
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...... UNIX for Dummies Questions & Answers
0
UNIX for Dummies Questions & Answers
postfix - reinject mail to postfix from hold queue directory
coolatt
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...... IP Networking
0
IP Networking
UNIX and Linux

Unix (trademarked as the UNIX certification mark) is a very mature family of multitasking, multiuser computer operating systems that evolved from the original AT&T Unix. Unix development starting in the 1970s by legendary Bell Labs programmers Ken Thompson, Dennis Ritchie, and others. Unix was first targeted for the Bell System and AT&T licensed Unix to outside parties. In the 1970s time period, this lead to a variety of for-profit as well as not-for-profit Unix variants.
In the early days, this included the University of California, Berkeley (BSD), Microsoft (Xenix), IBM (AIX), and Sun Microsystems (Solaris). In the early 1990s, AT&T sold their Unix rights to Novell. In 1995 Novell sold their Unix business to the Santa Cruz Operation (SCO). The UNIX trademark was passed to The Open Group, a "neutral" industry consortium. The Open Group promoted the use of the UNIX trademark for certified operating systems that comply with the Single UNIX Specification (SUS). In 2014 Apple's macOS became the Unix version with the largest global install base and macOS remains the largest Unix-user base today.
Linux is a family of open source Unix-like operating systems based on the Linux kernel. The Linux kernel is an operating system kernel first released by Linus Torvalds on 17 September 1991. Linux distributions include the Linux kernel, system software and libraries. Popular free open source Linux distributions include Debian, Fedora, and Ubuntu. Commercial Linux distributions include Red Hat Enterprise Linux and SUSE Linux Enterprise Server. Linux may be freely modified and redistributed. Anyone on the planet may create a Linux distribution for any purpose.
Please enjoy and help our forum community by "showing your work" and posting your code, even when your code is not working as expected. To help others help you, please wrap your code blocks, sample input, sample output, error messages, and other data in CODE tags and wrap your short commands and short data objects in ICODE tags. We were all beginners in the beginning. If you have any questions about how to register or how to post, please contact us in Live Chat. Thank you and enjoy this "forever free" technical support community for UNIX, Linux and computer information technology in general.