This is a RHEL4.1 box. Switching over from a Gentoo box, I prefer to have much more control over how my mail system is compiled and installed.
So first:
yum remove sendmail
I’ll be setting up postfix from source, configuring it to use a mysql database for virtual hosting, adding spam trapping/management, webmail, and vacation. And of course I need to setup both IMAP and POP3 in secure and unsecure versions, as well as some port forwarding to get around some braindead ISP policies. Finally, I will need to set up automated backup for the IMAP and webmail accounts.
This server will need to support SASL and TLS. But for a starting configuration, I build a version just with the mysql support. Once the main portions of the delivery chain are working, then it will be easier to enable the additional bells and whistles.
For MySQL support:
- Add -DHAS_MYSQL and -I/include/directory/for/mysqlclient-library to the CCARGS
- Add -L/path/to/mysqlclient-library, -lmysqlclient -lz and -lm to AUXLIBS
- Requires: mysqlclient, libz and libm.
Mysql-only build:
make -f Makefile.init makefiles \
'CCARGS=-DHAS_MYSQL -I/usr/include/mysql' \
'AUXLIBS=-L/usr/lib/mysql/ -lmysqlclient -lz -lm'
make
I add users for postfix and postgroup per the basic postfix installation instructions. Then do a “make install” and accept the defaults for all the prompts. Next I add an entry to /etc/aliases directing root mail to kernd, then run “newaliases”.
I need to make a decision now on what interface I am going to run the mail server on. So I guess now would be a good time to allocate some hostnames.
Here is the interface allocation on this machine:
| Interface |
Address |
Hostname |
| eth0 |
74.53.36.82 |
sol |
| eth0:0 |
74.53.36.83 |
mercury |
| eth0:1 |
74.53.36.84 |
venus |
| eth0:2 |
74.53.36.85 |
earth |
| eth0:3 |
74.53.36.86 |
mars |
| eth0:4 |
74.53.36.87 |
ceres |
| eth0:5 |
74.53.36.88 |
jupiter |
| eth0:6 |
74.53.36.89 |
saturn |
| eth0:7 |
74.53.36.90 |
uranus |
| eth0:8 |
74.53.36.91 |
neptune |
| eth0:9 |
74.53.36.92 |
pluto |
| eth0:10 |
74.53.36.93 |
eris |
So now that I have some names allocated, and since I want email to be delivered quickly, “mercury” would be a good name for the mail server.
Set options in /etc/postfix/main.cf (some of these are defaults from the install):
queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
mail_owner = postfix
myhostname = mercury.reasonspace.com
mydomain = reasonspace.com
myorigin = $mydomain
inet_interfaces = 74.53.36.83
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
unknown_local_recipient_reject_code = 550
mynetworks = 74.53.36.82/31,74.53.36.84/30,74.53.36.88/30,74.53.36.92/31,127.0.0.0/8
home_mailbox = Maildir/
alias_maps = hash:/etc/aliases
Then give “postfix start” and check /var/log/maillog for any errors. A “netstat -tna” shows that the SMTP server is listening on the correct address. Telneting to port 25 on that IP lets me correctly send an email to a local user and to a remote user. So the basic configuration is working.