Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have set up a Postfix server with SMTP AUTH (STARTTLS on port 587). All my users are in the domain "example.org". I want to enforce the sender address to be "logged-in-user@example.org".

I learned that this can be achieved with the main.cf options

smtpd_sender_restrictions = reject_sender_login_mismatch, ...
smtpd_sender_login_maps = hash:/etc/postfix/smtpd_sender_login_maps

with a login_maps file like:

a@example.org a
b@example.org b
c@example.org c

(see also Block sender address spoofing with SMPT AUTH), but this would mean I'll have to edit the login_maps file every time I have a new user. I don't need such a flexible mapping: It should always be "logged-in-user@example.org". Is there an easier option?

share|improve this question

2 Answers 2

up vote 6 down vote accepted

You need pcre regex compiled in Postfix. Or the distribution already includes pcre. postconf -m should show a line with pcre in it. And then you can do:


/^(.*)@example.org$/   ${1}

In main.cf:

smtpd_sender_login_maps = pcre:/etc/postfix/login_maps.pcre

Should work fine as expected. If not let me know so that I edit it when needed.

share|improve this answer
This is perfect. Exactly what I was looking for! –  Chris Lercher Oct 4 '11 at 18:56

Can you use combination of regexp on the header as shown here: http://www.akadia.com/services/postfix_uce.html? Then you can combine with regexp like [*@example.org] to ensure only sender from example.org.

share|improve this answer
Let's assume, I can use "regexp:" here (?) How can I specify the regexp such, that user "a" can send as "a@example.org" but not as "b@example.org"? –  Chris Lercher Oct 4 '11 at 14:58

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.