The Tutor: Replacing Sendmail with Postfix
Total Page:16
File Type:pdf, Size:1020Kb
102answergirl.qxd 23.10.2000 16:04 Uhr Seite 102 BEGINNERS TROUBLESHOOTING The Tutor POSTING THE MAILPATRICIA JUNG Computers can often give you a surprise, even under Linux. Often things don’t work as they are actually meant to. The Tutor shows you how to deal with these little problems. It’s unusual in the Windows world for a home or grounds (services which are not made available workstation PC to be equipped with its own mail by your own computer can’t be abused or server, but in Linux installations the SMTP server attacked by net baddies) or to conserve (also known as MTA – ”Mail Transfer Agent”) is part resources, why not use your local SMTP server of the basic system, for good reason. Without it, when sending mail, and be independent of your programs like Cron Daemon, which controls the access provider? automatic processing of specified tasks at pre- defined times, have a bit of a problem, as they like It doesn’t have to be Sendmail sending both failure and success messages by mail to the local user concerned. Many distributions have the grandfather of MTAs Even if, as a home user, you switch off as Sendmail pre-installed. This program is very powerful many Internet servers as possible on safety but has one major drawback: its configuration file, /etc/sendmail.cf, is written in such a way that wile it is easy for machines to understand it is more or less SMTP: ”Simple Mail Transfer Protocol” is a convention for how email is incomprehensible to humans. transported through the Internet. In the versions of sendmail now commonly used it is possible to create an easily Daemon: A class of program (the name comes from ”disk and execution understandable sendmail.mc file and transcribe monitor”) that is started at boot-up and runs in the background performing this using the m4 pre-processor into a suitable some essential service for the system. sendmail.cf. But in all honesty, do you trust yourself to configure a program correctly and Cron: The time daemon (cron or crond, depending on the distribution) deals with satisfactorily, whose version number you can’t tasks specified in Crontabs (”Cron tables”) at the time specified therein. find usingsendmail -v or sendmail –version, but only by means of /usr/sbin/sendmail -d0 -bt < I /dev/null ? 102 LINUX MAGAZINE 3 · 2000 102answergirl.qxd 23.10.2000 16:04 Uhr Seite 103 TROUBLESHOOTING BEGINNERS Many problems with Sendmail arise only because even fairly proficient Unix users don’t have the Symbolic link: A reference to another file created using the command ln -s. By energy to plough through several hundred pages of this means a file can be addressed by different names. documentation. The upshot of this has been that setting up your own mail server is generally Dependencies: Classic Unix programs require that they can dispose of the considered to be a task achievable by only the most emails they create using a local mail server: they depend on it in such a way wizened of gurus. that their presence on a computer without an MTA would be pointless. Each rpm or deb package contains information about this dependency so that the Alternatives package manager will warn you if you try to install a program that requires an MTA when one is not present, or if you try to uninstall an MTA when It doesn’t have to be like that, though. Such user- other programs are installed that depend on it. It will also prevent you from hostility has even bothered the gurus, providing installing different MTAs side by side, because some of the settings needed them with just the excuse they needed to go off and will clash. write their own mail server. So now there are a wide variety of Sendmail alternatives ranging from the POP: The ”Post Office Protocol” provides a way to receive mail even when not ”little” smail via Postfix, Exim, Zmailer (which was constantly online to your ISP’s SMTP server. The POP server plays post-box and specially optimised for heavily-used mailservers) to allows the user to pick up mails collected (by SMTP) at a later time using a Qmail, which really does take some getting used to. suitable tool (for example, fetchmail) or a POP-compatible mail program. All are usable to some extent by applications designed to work with Sendmail. So for reasons of I compatibility there is always a symbolic link named /usr/sbin/sendmail. Thanks to -v (”verbose”) we learn that Sendmail For the home user, optimal behaviour of the and Postfix are mutually incompatible. MTA under a heavy load – a key criterion for All right, we’ll solve the problem by uninstalling (-e internet service providers, universities or big as ”erase”) the sendmail package … companies – doesn’t matter. The most important [root<\@>pc software]# rpm -e sendmail thing in this situation is good documentation and error: removing these packages would break dU comparatively simple installation and configuration. ependencies: All three criteria together are satisfied best, in my smtpdaemon is needed by fetchmail-5.3.1-1 experience, by Postfix (http://www.informatik.uni- smtpdaemon is needed by mutt-1.0.1i-6 bonn.de/pub/software/postfix/start.html). smtpdaemon is needed by nmh-1.0.3-6x Escaping from Sendmail … or maybe not: The installed mail programs mutt and nmh and the POP client fetchmail absolutely Postfix has the additional advantage that it comes will not relinquish their SMTP server. Without this, with many distributions as an rpm or deb archive, or their functionality would be affected, and as rpm is at least available as such. Red Hat users won’t doesn’t know that we are immediately going to actually find the package in the core distribution, provide them with a new replacement mail server, it but in powertools (e.g. at ftp://ftp.redhat.com/pub/ gets awkward. redhat/powertools/6.2/i386/i386/). Who is the boss here? The rpm man page, Since a whole range of programs can only be despite all its complexity, is really helpful in this installed using a package manager if the latter is situation. It reveals that by using the option aware of the existence of an MTA, it is essential in –nodeps (”no dependencies”) the package order to avoid later problems to install the SMTP manager can be made to understand that it should server using the package manager, too. Otherwise simply overlook dependencies. rpm or dpkg are almost unbeatable for But it’s better to be safe than sorry: After stubbornness. installing Postfix, is everything now in order for our This is exactly the problem we have to combat sendmail-loving mail assistants? Let’s just ask when we want to use something instead of (”query”: -q) the Postfix rpm package (-p as Sendmail. In the first instance, simple installation (-i) ”package”), to see what it actually makes available of the Postfix package as root doesn’t work: (–provides). [root<\@>pc software]# rpm -ivh [trish<\@>pc software]$ rpm -qp —provides postfix-19991231_pl02-4.i386.rpm postfix-19991231_pl02-4.i386.rpm error: failed dependencies: MTA sendmail conflicts with postfix-19991U smtpd 231_pl02-4 smtpdaemon The option -h (as in ”hash”, meaning to use # The answer tells us we can take the momentous step symbols as a progress indicator) shows that nothing of uninstalling Sendmail with an untroubled mind: has happened because rpm flatly refuses to load a The smtpdaemon that mutt, fetchmail and nmh all package whose dependencies are not fulfilled. need will be restored by the Postfix installation. 3 · 2000 LINUX MAGAZINE 103 102answergirl.qxd 23.10.2000 16:04 Uhr Seite 104 BEGINNERS TROUBLESHOOTING So we can now try again to remove sendmail: Postfix is a daemon, and like all such programs there is a start-stop file for it in the directory init.d [root<\@>pc software]# rpm -e —nodeps sendmail [root<\@>pc software]# rpm -ivh postfix-1999U (”Initialisation of Daemons”), which, depending on 1231_pl02-4.i386.rpm the distribution, can be found under /etc, /etc/rc.d, postfix /sbin etc. (Exotic distributions like Slackware, which ###########################################U don’t use this logical System-V Init concept, are ####### something we will avoid discussing at this point.) postfix-script: warning: creating missing PoU stfix pid directory If you change (using cd) into this directory, all postfix-script: warning: creating missing PoU you need is the command ./postfix start (note the stfix incoming directory dot slash, ”./” in the path) before trying telnet [...] localhost smtp once again: postfix-script: warning: creating missing PoU stfix private directory Trying 127.0.0.1... Connected to localhost. rpm is no longer carping that we are destroying Escape character is ‘^]’. package dependencies by deleting sendmail (-e), 220 computername ESMTP Postfix and with it uninstalled we also see a bit of the progress indicator (-h). Because verbosity is switched on (-v) we learn from rpm that when loading in the If I were a mail program postfix packages a couple of directories which were not previously available (”directories”) named pid, Anyone who would now like to know how mail incoming etc. have now been set up. programs (alias ”Mail User Agents” – MUA) and SMTP servers converse, should enter the command So long as it stays at home... help now. Postfix reacts with a curt: 502 Error: command not implemented Even if you are not quite confident enough to use this server to send messages into the big, wide Shame, we ought to have done that first when we still world, at least local users can now send emails to had access to Sendmail.