Setting Up The Postfix Mail System: Peter Ross

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Setting up the Postfix mail system http://www.soc.napier.ac.uk/~peter/linux/postfix.

html

Setting up the Postfix mail system


Peter Ross

These notes describe how to set up the Postfix mail system on your Linux box
so that you can send out emails via a Napier University Microsoft Exchange
server. The notes assume that you are using Linux Mandrake 10.0, although
they very probably apply to any other Linux system that has Postfix too.

See here if you want some ideas of why you should even bother.

What is Postfix? It is a mail delivery agent, not a program for actually letting
you read and reply to your emails. The old-timer of such mail delivery agents is
sendmail, which is notoriously hard to configure correctly for any but the
simplest of set-ups. Postfix is a more modern replacement that is very much
easier to configure.

How do you know if you've got it installed? One simple way is to list all the
installed packages with the command rpm -qa and extract from that list any
occurrence of the string "postfix", in a case-independent way:

% rpm -qa | grep -i postfix

How do you know if it's active? Check whether it gets started at boot time, by
using one of the standard tools such as the Mandrake Control Centre (alias
/usr/X11R6/bin/DrakConf) to examine/change which services are running and
whether they are to be started at boot time.

How do you configure it? You need to edit the file /etc/postfix/main.cf (as
root) as follows:

set mydomain = napier.ac.uk although this is actually the effective


default
set myorigin = $myhostname so that a message composed by local user
`fred will have a header which says it comes from
fred@pc162119.napier.ac.uk (or whatever your PC's hostname is)
set mydestination = $myhostname, localhost.$mydomain so that
messages to another user on your own machine (eg, warning messages
generated by some other program to `root' (rather than, eg,
`root@mit.edu') or to `root@localhost.napier.ac.uk' get delivered without
the message ever leaving your machine.
set relayhost = ex-server1.napier.ac.uk so that messages which are not
to be delivered to another user on your machine (probably nearly all
messages will be to outsiders) are to be passed to an Exchange server; it

1 de 4 24-10-2010 12:04
Setting up the Postfix mail system http://www.soc.napier.ac.uk/~peter/linux/postfix.html

will then take care of delivery to wherever. (Note June 19 2004:


smtp.napier.ac.uk should handle outgoing mail, even from external
machines, but seems to be rejecting connections).
the Exchange server will not accept delivery requests from anyone
anywhere; you have to be authorised, and the authorisation procedure
involves Postfix telling the Exchange server your login name (eg cs999)
and corresponding password. To get Postfix to do this, insert
smtp_sasl_auth_enable = yes
smtp_sasl_security_options = noanonymous
smtpd_sasl_local_domain = $myhostname
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd

The second of these tells Postfix not to try anonymous login with the
Exchange server. The fourth line tells it where to look up the appropriate
login/password info. You need to create the file /etc/postfix/sasl_passwd
to contain, eg, the single line:
ex-server1.napier.ac.uk cs999:steamer6

assuming steamer6 is the relevant password for NAPIER-MAIL\cs999.


Then you have to get this plaintext information converted into database
format; in the directory /etc/postfix, as root, run the command:
# postmap sasl_passwd

and it will create the file sasl_passwd.db. Note that SASL is actually
something distinct from Postfix -- SASL stands for Simple Authentication
and Security Layer and is a separate software library designed to manage
various possible authentication dialogues for connection-based
communication protocols such as TCP/IP. The SASL software may or may
not be already installed on our system, see below.
finally, somewhere, add these two lines:
sender_canonical_maps = hash:/etc/postfix/sender_canonical
recipient_canonical_maps = hash:/etc/postfix/recipient_canonical

These files will contain details for rewriting certain outbound and inbound
email addresses, see below.

This should be all you need to do to /etc/postfix/main.cf (but do read the rest
and see if there is anything else you wan to tweak). But there is more still to
do!

Check that you have SASL installed:


% rpm -qa | grep -i sasl

You will need at least these (the version numbers may vary):

2 de 4 24-10-2010 12:04
Setting up the Postfix mail system http://www.soc.napier.ac.uk/~peter/linux/postfix.html

libsasl2-2.1.15-10mdk
libsasl2-plug-login-2.1.15-10mdk

but if you want to cope with all the standard sorts of dialogue, for example
because you also want to send mail via your favourite external ISP, then you
would also need:
libsasl2-plug-anonymous-2.1.15-10mdk
libsasl2-plug-plain-2.1.15-10mdk
libsasl2-plug-crammd5-2.1.15-10mdk
libsasl2-plug-srp-2.1.15-10mdk
libsasl2-plug-digestmd5-2.1.15-10mdk
libsasl2-plug-otp-2.1.15-10mdk
libsasl2-plug-gssapi-2.1.15-10mdk
libsasl2-plug-sasldb-2.1.15-10mdk
libsasl2-plug-ntlm-2.1.15-10mdk

To find these RPMs look at http://rpmfind.net and search for libsasl2-plug

Create the file /etc/postfix/sender_canonical to contain something like these


two lines, or whatever:

peter@pc162119.napier.ac.uk P.Ross@napier.ac.uk
peter@localhost.napier.ac.uk P.Ross@napier.ac.uk

This means that a message from `peter', originally rewritten to be from


'peter@pc162119.napier.ac.uk' thanks to the myorigin variable mentioned
above, will then be rewritten to be from P.Ross@napier.ac.uk. That means that
when somebody replies, the reply will go to the Exchange server and will be
stored there ... until it gets collected, see below. Also create the file
/etc/postfix/recipient_canonical to contain something like
peter@pc16219.napier.ac.uk peter
peter@napier.ac.uk peter
peter@localhost.napier.ac.uk peter
P.Ross@napier.ac.uk peter
P.Ross peter

This lot is essentially a belt-and-braces measure. If, at some stage in the future,
you adjust the mail setup to also accept messages from external hosts, then
inbound messages addressed to any of these will be delivered to peter locally.
And, of course, you need to get these text files turned into database format by
these commands in the directory /etc/postfix:
# postmap sender_canonical
# postmap recipient_canonical

Finally, you need to get Postfix to notice all these changes you have made. Get
it to re-read its configuration information by the command:
# postfix reload

3 de 4 24-10-2010 12:04
Setting up the Postfix mail system http://www.soc.napier.ac.uk/~peter/linux/postfix.html

and you should now be able to send email to anyone anywhere, and their
replies will come back to the Exchange server and await your pleasure there.

Of course, you may not want to use Outlook on a Windows box to read your
email on the Exchange server, you may prefer to collect it and have it delivered
to you on your Linux box. The simplest way to do this is to use the fetchmail
program. You will need a $HOME/.fetchmailrc file that contains something like
this:

poll imap.napier.ac.uk protocol IMAP auth password


user "NAPIER-MAIL\\cs999\\P.Ross" with password "steamer6" is "peter" here

This does not have to be all on one line. You can get fetchmail to run every few
minutes -- see the man page, or use one of the standard command-scheduling
tools such as at and cron.

4 de 4 24-10-2010 12:04

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy