relay_postfix

Embed Size (px)

Citation preview

  • 8/7/2019 relay_postfix

    1/4

    Setting up the Postfix mail system

    Peter Ross

    These notes describe how to set up the Postfix mail system on your Linux boxso that you can send out emails via a Napier University Microsoft Exchangeserver. The notes assume that you are using Linux Mandrake 10.0, althoughthey 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 lettingyou read and reply to your emails. The old-timer of such mail delivery agents issendmail, which is notoriously hard to configure correctly for any but thesimplest 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 theinstalled packages with the command rpm -qa and extract from that list anyoccurrence 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, byusing 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(asroot) as follows:

    set mydomain = napier.ac.ukalthough this is actually the effectivedefaultset myorigin = $myhostname so that a message composed by local user`fred will have a header which says it comes [email protected] (or whatever your PC's hostname is)set mydestination = $myhostname, localhost.$mydomain so that

    messages to another user on your own machine (eg, warning messagesgenerated by some other program to `root' (rather than, eg,`[email protected]') or to [email protected]' get delivered withoutthe message ever leaving your machine.set relayhost = ex-server1.napier.ac.ukso that messages which are notto be delivered to another user on your machine (probably nearly allmessages will be to outsiders) are to be passed to an Exchange server; it

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

    de 4 24-10-2010 1

  • 8/7/2019 relay_postfix

    2/4

    will then take care of delivery to wherever. (Note June 19 2004:smtp.napier.ac.uk should handle outgoing mail, even from externalmachines, but seems to be rejecting connections).the Exchange server will not accept delivery requests from anyoneanywhere; you have to be authorised, and the authorisation procedureinvolves Postfix telling the Exchange server your login name (eg cs999)

    and corresponding password. To get Postfix to do this, insertsmtp_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 theExchange server. The fourth line tells it where to look up the appropriatelogin/password info. You need to create the file /etc/postfix/sasl_passwdto 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 databaseformat; 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 actuallysomething distinct from Postfix -- SASL stands for Simple Authenticationand Security Layerand is a separate software library designed to managevarious possible authentication dialogues for connection-based

    communication protocols such as TCP/IP. The SASL software may or maynot 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 inboundemail addresses, see below.

    This should be all you need to do to /etc/postfix/main.cf(but do read the restand 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):

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

    2 de 4 24-10-2010 1

  • 8/7/2019 relay_postfix

    3/4

  • 8/7/2019 relay_postfix

    4/4

    and you should now be able to send email to anyone anywhere, and theirreplies 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 youremail on the Exchange server, you may prefer to collect it and have it deliveredto 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 likethis:

    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 fewminutes -- see the man page, or use one of the standard command-schedulingtools such as at and cron.

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

    4 de 4 24-10-2010 1