Configure Postfix for authenticated Simple Mail Transfer Protocol (SMTP)

Thứ tư - 22/10/2008 16:51

Postfix can be configured to relay mail for users at remote locations with a valid username and password combination. Following this guide will allow Authenticated SMTP and passwords to be sent in plain text. A secure transport layer should be implemented to ensure that usernames and passwords can not be eavesdropped while in transit.

Authenticated SMTP requires users who are not in the "mynetwork" directive within /etc/postfix/ to supply a valid username and password before the mail server will forward mail.

This configuration requires Postfix to be installed and be configured to accept incoming mail on an Internet facing interface.

  1. Open /etc/postfix/ with your editor and add the line smtpd_sasl_auth_enable = yes

    smtpd_sasl_auth_enable = yes

    This line informs Postfix to enable SMTP AUTH when users not in the mynetwork directive attempt to send mail using this Postfix mail server to users not in the domain which Postfix has been configured to listen on.

  2. Also in /etc/postfix/, add smtpd_sasl_security_options=noanonymous


    This disables anonymous style logins for SMTP AUTH. Without this line anyone will be able to use your machine as an open relay.

  3. Again in /etc/postfix/, add the smtpd_recipient_restrictions as specified below:

    smtpd_recipient_restrictions = permit_sasl_authenticated, permit_mynetworks,reject_unauth_destination, check_relay_domains

    This line sets the restrictions for clients attempting to relay mail through your mail server.

  4. Edit /etc/sysconfig/saslauthd and set the value of MECH (Abbrevition of the word mechanism) to pam:


    Setting this value to pam, sets saslauthd to use the local Plugguable Authentication Modules (PAM) subsystem to validate each username and password.

  5. Ensure that saslauthd will start on boot by adding it to the third and fifth runlevels.

    /sbin/chkconfig --level 35 saslauthd on

  6. Start or restart the saslauthd service:

    /sbin/service saslauthd start/sbin/service saslauthd restart

  7. Finally start or restart Postfix:

    /sbin/service postfix start/sbin/service postfix restart


The Postfix server should now be started and allow relaying of mail from authenticated clients. You can confirm this by connecting to the mail server using the telnet application.

Most communication with the mail server can be done in plain text, but the authentication information must be encoded in Base64.

You can generate this information by modifying the line below, replacing the username and password with a valid username and password that can be authenticated by the Postfix server.


perl -MMIME::Base64 -e 'print encode_base64("usernameusernamepassword");'

It should produce a string similar to the format below.








Do not loose the generated string as it will be used shortly.

Authentication can be tested by connecting to the mail server with telnet and manually entering the SMTP information.

In the example below the section in bold is what should be typed. Replace the string after AUTH PLAIN with the Base64 string created above











# telnet 25Trying to ( character is '^]'.220 ESMTP PostfixEHLO 250-mail.example.com250-PIPELINING250-SIZE 10240000250-VRFY250-ETRN250-STARTTLS250-AUTH PLAIN LOGIN GSSAPI DIGEST-MD5 CRAM-MD5250-XVERP250 8BITMIMEAUTH PLAIN dXNlcm5hbWUAdXNlcm5hbWUAcGFzc3dvcmQ= 235 Authentication successfulQUIT 221 Bye

The line "250-AUTH PLAIN LOGIN GSSAPI DIGEST-MD5 CRAM-MD5" shows that the Postfix server allows users to authenticate.

For more information, visit the Red Hat Postfix HOWTO.






Tổng số điểm của bài viết là: 0 trong 0 đánh giá

Click để đánh giá bài viết

  Ý kiến bạn đọc

Giới thiệu

Cộng đồng Fedora Việt Nam

Sứ mệnh của dự án Fedora là tập hợp, dẫn dắt các tiến bộ của phần mềm và nội dung tự do nguồn mở trong một cộng đồng hợp tác, thông qua việc: Không ngừng phấn đấu để luôn đi đầu Không ngừng tìm tòi, sáng tạo, vươn lên và truyền bá phần mềm và nội dung tự do Chia sẻ thành công với toàn thể cộng...

Đăng nhập thành viên
Hãy đăng nhập thành viên để trải nghiệm đầy đủ các tiện ích trên site
Thống kê truy cập
  • Đang truy cập53
  • Hôm nay12,236
  • Tháng hiện tại383,078
  • Tổng lượt truy cập7,522,883
Fedora Project

Fedora is always free for anyone to use, modify, and distribute. It is built and used by people across the globe who work together as a community: the Fedora Project.

Bạn đã không sử dụng Site, Bấm vào đây để duy trì trạng thái đăng nhập. Thời gian chờ: 60 giây