Detailed Mail Server Setup – FreeBSD
This is a rough note I took down while setting up Mail Server for our school. Corrections are welcome.
This setup is composed of Postfix, Dovecot, ClamAV, Mailscanner, Apache, PHP, MySQL, and Horde Groupware Mail.
Desclaimer: This tutorial is based on similar tutorials I have collected from the internet. This was tested only once but it worked for us. Use this at your own risk.
Take note that I am assuming your FreeBSD box has been installed already. At the time of this writing, the latest version was 7.2. In case you don’t know how to install it, you can check out this site.
Before anything else update FreeBSD ports:
Upgrade relevant ports collections so we dont snafu in between!
#cd /opt/mail
#fetch http://bsdinn.com/dl/ports.mailserver
#csup -g -L 2 ports.mailserver
Install openssl:
#cd /usr/ports/security/openssl
#make deinstall
#make reinstall
Install Postfix
#make install clean
Select PCRE, SASL, DOVECOT,TLS,MYSQL, VDA, SASL2, SSL, and TLS options
Answer ‘y’ to all questions
Add this to /etc/rc.conf
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”
Put this in /etc/defaults/periodic.conf
daily_status_mail_rejects_enable=”NO”
daily_status_include_submit_mailq=”NO”
daily_submit_queuerun=”NO”
Create the aliases.db run
(The can be done without editing your /etc/aliases file. However, if you’d like your root emails to be mailed to someone besides the local root user, you can edit the file and change the ‘root: root’ to ‘root: you@domain.tld’.
Create the transport.db:
#/usr/local/sbin/postmap /usr/local/etc/postfix/transport
Restart Postfix:
postfix/postfix-script: stopping the Postfix mail system
#/usr/local/etc/rc.d/postfix start
postfix/postfix-script: starting the Postfix mail system
# /usr/local/etc/rc.d/postfix status
postfix/postfix-script: the Postfix mail system is running: PID: 53559
Edit main.cf and set mail_spool_directory to /var/spool/mail which is where the messages will be queued.
Search “maiL_spool_directory” and a block of texts will have these two lines:
# mail_spool_directory = /var/spool/mail
Remove the comment so it would look like this:
mail_spool_directory = /var/spool/mail
Save and exit…
Test postfix..
mail from: fbm
rcpt to: fbm
data —–>> press enter then type a message
hello sir mondia —>> press enter
test to fbm
—–>> blank message here. just press enter..
—–>> another blank message.. enter period “.”
—–>> press enter again…
It should prompt you that the message has been queued, to be sent to fbm…
Check if the message has been queued…
# ls
# cat fbm
You should see the message you just sent including the “hello sir mondia phrase”. Note that the argument for cat depends on who you sent the message to. This should be the message:
Return-Path: <fbm@xu.edu.ph>
X-Original-To: fbm
Delivered-To: fbm@xu.edu.ph
Received: from localhost (unknown [127.0.0.1])
by mailx.xu.edu.ph (Postfix) with ESMTP id BE0397E2437
for <testuser>; Sun, 7 Jun 2009 11:49:13 +0800 (PHT)
Message-Id: <20090607034926.BE0397E2437@mailx.xu.edu.ph>
Date: Sun, 7 Jun 2009 11:49:13 +0800 (PHT)
From: fbm@xu.edu.ph
To: undisclosed-recipients:;
test data from fbm to fbm
105 1:25pm /var/spool/mail #
Install Dovecot IMAP, IMAP-SSL, POP3 and POP3-SSL servers
#make install
#ee /usr/local/etc/dovecot.conf
Find the following keys and change its values as follows:
mail_location = mbox:~/mail:INBOX=/var/spool/mail/%u
pop3_uidl_format = %08Xu%08Xv
imap_client_workarounds = delay-newmail outlook-idle netscape-eoh – note: outlook-idle note found
pop3_client_workarounds = outlook-no-nuls oe-ns-eoh
If starting dovecot complains about ssl certificates, disable ssl support:
Search for ssl string then disable it.
No comments yet.