Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have almost default configuration of Postfix

How can I configure Postfix to ask for username/password before relaying mail from other than "mynetworks" IP's?

Thank You very much

share|improve this question
up vote 1 down vote accepted

So SASL on postfix is a pain to configure.

The magic lines are:

# In each of these:
smtpd_*_restrictions = permit_mynetworks, permit_sasl_authenticated, ...
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_sasl_local_domain = $myhostname
smtpd_sasl_authenticated_header = yes
broken_sasl_auth_clients = yes

You need TLS to ensure data security, the files are a standard SSL key pair:

smtpd_use_tls = yes

You'll also want to listen on the SMTP submission port, that needs something like:

submission inet n       -       -       -       -       smtpd
  -o smtpd_enforce_tls=yes
  -o smtpd_client_restrictions=permit_sasl_authenticated,reject

Actually configuring the SASL backend is highly dependent on what your authentication source is, so I'd need for info to suggest on that.

share|improve this answer
Thank You very much for your answer – Daniil Harik Apr 10 '10 at 14:19
This still doesnt say where/how you create the user to authenticate – Christian Feb 10 '15 at 10:45

What you are looking for is Postfix with SASL Authentication. You will need the Cyrus SASL library to authenticate your users but it's also possible to use dovecot for that.

Dovecot is my favorite, most likely you need an POP3/IMAP (and LDA) service anyway. With dovecot it's very easy to authenticate your users against the same database as your POP3/IMAP users. has a guide on how to setup Postfix / SASL with Dovecot / Cyrus:

share|improve this answer

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.