Sunday, January 23, 2011

Postfix allow relay with username and password

Hello,

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

  • 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. Postfix.org has a guide on how to setup Postfix / SASL with Dovecot / Cyrus: http://www.postfix.org/SASL_README.html.

    From PowerSp00n
  • So SASL on postfix is a pain to configure.

    The magic lines are:

    # main.cf
    # 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_tls_cert_file=PEM-FILE-NAME
    smtpd_tls_key_file=KEY-FILE-NAME
    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.

    Daniil Harik : Thank You very much for your answer
    From LapTop006

0 comments:

Post a Comment