Personal tools
You are here: Home Documentation How-tos How to Replace Sendmail with Postfix Under FreeBSD
Document Actions

How to Replace Sendmail with Postfix Under FreeBSD

This How-to applies to: FreeBSD 5.x, Postfix 2.x

While FreeBSD's default Sendmail configuration is relatively secure (in that it opens a submission-only listener on the loopback interface), Sendmail is difficult to configure and has a history of security-related problems. I replace Sendmail with Postfix and configure it to relay mail through a proxy instead of delivering mail directly.

You can find the Postfix web site at http://www.postfix.org/.

  1. Stop Sendmail prior to installing Postfix. The Postfix installation will modify the startup/shutdown scripts, making it more difficult to properly stop Sendmail if it is still running at that point.
    /etc/rc.d/sendmail stop
    
  2. Install Postfix from the ports tree and configure it to start at boot with the following commands:
    portinstall -m BATCH=yes mail/postfix
    ed
    a
    #
    # Execute the Postfix sendmail program, named /usr/local/sbin/sendmail
    #
    sendmail      /usr/local/sbin/sendmail
    send-mail     /usr/local/sbin/sendmail
    mailq         /usr/local/sbin/sendmail
    newaliases    /usr/local/sbin/sendmail
    .
    w /etc/mail/mailer.conf
    q
    ed /etc/rc.conf
    a
    sendmail_enable="YES"
    sendmail_flags="-bd"
    sendmail_pidfile="/var/spool/postfix/pid/master.pid"
    sendmail_procname="/usr/local/libexec/postfix/master"
    sendmail_outbound_enable="NO"
    sendmail_submit_enable="NO"
    sendmail_msp_queue_enable="NO"
    .
    wq
    
  3. Disable FreeBSD's default Sendmail-specific mail maintenance routines with the following commands:
    ed
    a
    daily_clean_hoststat_enable="NO"
    daily_status_mail_rejects_enable="NO"
    daily_status_include_submit_mailq="NO"
    daily_submit_queuerun="NO"
    .
    w /etc/periodic.conf
    q
    
  4. Reconfigure Postfix to listen only on the loopback interface, mimicing sendmail's default listener configuration, with the following command:
    sed -i '' -e 's/^smtp *inet/localhost:smtp inet/' /usr/local/etc/postfix/master.cf
    
  5. Optional: In their default configurations, both sendmail and Postfix will try to deliver messages directly to their destinations. If desired, you can configure Postfix to relay mail through a proxy with the relayhost setting. Reconfigure Postfix to relay to the mail exchangers of the computer's DNS domain (as listed in that domain's MX records) with the following commands:
    ed /usr/local/etc/postfix/main.cf
    a
    relayhost = $mydomain
    .
    wq
    
    If you prefer to relay through a specific host, use these commands instead (replacing mail.example.com with the host name or IP address of your relay):
    ed /usr/local/etc/postfix/main.cf
    a
    relayhost = [mail.example.com]
    .
    wq
    
  6. Start Postfix with the following command:
    /etc/rc.d/sendmail start
    
by Matthew X. Economou last modified 2005-09-28 17:45
Advertisements
 

Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: