📄 mail-changingmta.html
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta name="generator" content="HTML Tidy, see www.w3.org" /><title>Changing Your Mail Transfer Agent</title><meta name="GENERATOR" content="Modular DocBook HTML Stylesheet Version 1.7" /><link rel="HOME" title="FreeBSD Handbook" href="index.html" /><link rel="UP" title="Electronic Mail" href="mail.html" /><link rel="PREVIOUS" title="sendmail Configuration" href="sendmail.html" /><link rel="NEXT" title="Troubleshooting" href="mail-trouble.html" /><link rel="STYLESHEET" type="text/css" href="docbook.css" /></head><body class="SECT1" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#840084"alink="#0000FF"><div class="NAVHEADER"><table summary="Header navigation table" width="100%" border="0" cellpadding="0"cellspacing="0"><tr><th colspan="3" align="center">FreeBSD Handbook</th></tr><tr><td width="10%" align="left" valign="bottom"><a href="sendmail.html"accesskey="P">Prev</a></td><td width="80%" align="center" valign="bottom">Chapter 22 Electronic Mail</td><td width="10%" align="right" valign="bottom"><a href="mail-trouble.html"accesskey="N">Next</a></td></tr></table><hr align="LEFT" width="100%" /></div><div class="SECT1"><h1 class="SECT1"><a id="MAIL-CHANGINGMTA" name="MAIL-CHANGINGMTA">22.4 Changing YourMail Transfer Agent</a></h1><i class="AUTHORGROUP"><span class="CONTRIB">Written by</span> Andrew Boothman.</i> <iclass="AUTHORGROUP"><span class="CONTRIB">Information taken from e-mails writtenby</span> Gregory Neil Shapiro.</i> <p>As already mentioned, FreeBSD comes with <b class="APPLICATION">sendmail</b> alreadyinstalled as your MTA (Mail Transfer Agent). Therefore by default it is in charge of youroutgoing and incoming mail.</p><p>However, for a variety of reasons, some system administrators want to change theirsystem's MTA. These reasons range from simply wanting to try out another MTA to needing aspecific feature or package which relies on another mailer. Fortunately, whatever thereason, FreeBSD makes it easy to make the change.</p><div class="SECT2"><h2 class="SECT2"><a id="AEN32175" name="AEN32175">22.4.1 Install a New MTA</a></h2><p>You have a wide choice of MTAs available. A good starting point is the <ahref="ports.html">FreeBSD Ports Collection</a> where you will be able to find many. Ofcourse you are free to use any MTA you want from any location, as long as you can make itrun under FreeBSD.</p><p>Start by installing your new MTA. Once it is installed it gives you a chance to decideif it really fulfills your needs, and also gives you the opportunity to configure yournew software before getting it to take over from <b class="APPLICATION">sendmail</b>.When doing this, you should be sure that installing the new software will not attempt tooverwrite system binaries such as <tt class="FILENAME">/usr/bin/sendmail</tt>. Otherwise,your new mail software has essentially been put into service before you have configuredit.</p><p>Please refer to your chosen MTA's documentation for information on how to configurethe software you have chosen.</p></div><div class="SECT2"><h2 class="SECT2"><a id="AEN32183" name="AEN32183">22.4.2 Disable <bclass="APPLICATION">sendmail</b></a></h2><p>The procedure used to start <b class="APPLICATION">sendmail</b> changed significantlybetween 4.5-RELEASE and 4.6-RELEASE. Therefore, the procedure used to disable it issubtly different.</p><div class="SECT3"><h3 class="SECT3"><a id="AEN32188" name="AEN32188">22.4.2.1 FreeBSD 4.5-STABLE before2002/4/4 and Earlier (Including 4.5-RELEASE and Earlier)</a></h3><p>Enter:</p><pre class="PROGRAMLISTING">sendmail_enable="NO"</pre><p>into <tt class="FILENAME">/etc/rc.conf</tt>. This will disable <bclass="APPLICATION">sendmail</b>'s incoming mail service, but if <ttclass="FILENAME">/etc/mail/mailer.conf</tt> (see below) is not changed, <bclass="APPLICATION">sendmail</b> will still be used to send e-mail.</p></div><div class="SECT3"><h3 class="SECT3"><a id="AEN32197" name="AEN32197">22.4.2.2 FreeBSD 4.5-STABLE after2002/4/4 (Including 4.6-RELEASE and Later)</a></h3><p>In order to completely disable <b class="APPLICATION">sendmail</b> you must use</p><pre class="PROGRAMLISTING">sendmail_enable="NONE"</pre><p>in <tt class="FILENAME">/etc/rc.conf.</tt></p><div class="WARNING"><blockquote class="WARNING"><p><b>Warning:</b> If you disable <b class="APPLICATION">sendmail</b>'s outgoing mailservice in this way, it is important that you replace it with a fully working alternativemail delivery system. If you choose not to, system functions such as <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=periodic&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">periodic</span>(8)</span></a> will beunable to deliver their results by e-mail as they would normally expect to. Many parts ofyour system may expect to have a functional <bclass="APPLICATION">sendmail</b>-compatible system. If applications continue to use <bclass="APPLICATION">sendmail</b>'s binaries to try to send e-mail after you have disabledthem, mail could go into an inactive <b class="APPLICATION">sendmail</b> queue, and neverbe delivered.</p></blockquote></div><p>If you only want to disable <b class="APPLICATION">sendmail</b>'s incoming mailservice, you should set</p><pre class="PROGRAMLISTING">sendmail_enable="NO"</pre><p>in <tt class="FILENAME">/etc/rc.conf</tt>. More information on <bclass="APPLICATION">sendmail</b>'s startup options is available from the <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=rc.sendmail&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">rc.sendmail</span>(8)</span></a> manualpage.</p></div></div><div class="SECT2"><h2 class="SECT2"><a id="AEN32222" name="AEN32222">22.4.3 Running Your New MTA onBoot</a></h2><p>You may have a choice of two methods for running your new MTA on boot, again dependingon what version of FreeBSD you are running.</p><div class="SECT3"><h3 class="SECT3"><a id="AEN32225" name="AEN32225">22.4.3.1 FreeBSD 4.5-STABLE before2002/4/11 (Including 4.5-RELEASE and Earlier)</a></h3><p>Add a script to <tt class="FILENAME">/usr/local/etc/rc.d/</tt> that ends in <ttclass="FILENAME">.sh</tt> and is executable by <tt class="USERNAME">root</tt>. The scriptshould accept <var class="LITERAL">start</var> and <var class="LITERAL">stop</var>parameters. At startup time the system scripts will execute the command</p><pre class="PROGRAMLISTING">/usr/local/etc/rc.d/supermailer.sh start</pre><p>which you can also use to manually start the server. At shutdown time, the systemscripts will use the <var class="LITERAL">stop</var> option, running the command</p><pre class="PROGRAMLISTING">/usr/local/etc/rc.d/supermailer.sh stop</pre><p>which you can also use to manually stop the server while the system is running.</p></div><div class="SECT3"><h3 class="SECT3"><a id="AEN32238" name="AEN32238">22.4.3.2 FreeBSD 4.5-STABLE after2002/4/11 (Including 4.6-RELEASE and Later)</a></h3><p>With later versions of FreeBSD, you can use the above method or you can set</p><pre class="PROGRAMLISTING">mta_start_script="filename"</pre><p>in <tt class="FILENAME">/etc/rc.conf</tt>, where <varclass="REPLACEABLE">filename</var> is the name of some script that you want executed atboot to start your MTA.</p></div></div><div class="SECT2"><h2 class="SECT2"><a id="AEN32245" name="AEN32245">22.4.4 Replacing <bclass="APPLICATION">sendmail</b> as the System's Default Mailer</a></h2><p>The program <b class="APPLICATION">sendmail</b> is so ubiquitous as standard softwareon <span class="TRADEMARK">UNIX</span>® systems that some software just assumes it isalready installed and configured. For this reason, many alternative MTA's provide theirown compatible implementations of the <b class="APPLICATION">sendmail</b> command-lineinterface; this facilitates using them as ``drop-in'' replacements for <bclass="APPLICATION">sendmail</b>.</p><p>Therefore, if you are using an alternative mailer, you will need to make sure thatsoftware trying to execute standard <b class="APPLICATION">sendmail</b> binaries such as<tt class="FILENAME">/usr/bin/sendmail</tt> actually executes your chosen mailer instead.Fortunately, FreeBSD provides a system called <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=mailwrapper&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">mailwrapper</span>(8)</span></a> thatdoes this job for you.</p><p>When <b class="APPLICATION">sendmail</b> is operating as installed, you will findsomething like the following in <tt class="FILENAME">/etc/mail/mailer.conf</tt>:</p><pre class="PROGRAMLISTING">sendmail /usr/libexec/sendmail/sendmailsend-mail /usr/libexec/sendmail/sendmailmailq /usr/libexec/sendmail/sendmailnewaliases /usr/libexec/sendmail/sendmailhoststat /usr/libexec/sendmail/sendmailpurgestat /usr/libexec/sendmail/sendmail</pre><p>This means that when any of these common commands (such as <ttclass="FILENAME">sendmail</tt> itself) are run, the system actually invokes a copy ofmailwrapper named <tt class="FILENAME">sendmail</tt>, which checks <ttclass="FILENAME">mailer.conf</tt> and executes <ttclass="FILENAME">/usr/libexec/sendmail/sendmail</tt> instead. This system makes it easyto change what binaries are actually executed when these default <ttclass="FILENAME">sendmail</tt> functions are invoked.</p><p>Therefore if you wanted <ttclass="FILENAME">/usr/local/supermailer/bin/sendmail-compat</tt> to be run instead of <bclass="APPLICATION">sendmail</b>, you could change <ttclass="FILENAME">/etc/mail/mailer.conf</tt> to read:</p><pre class="PROGRAMLISTING">sendmail /usr/local/supermailer/bin/sendmail-compatsend-mail /usr/local/supermailer/bin/sendmail-compatmailq /usr/local/supermailer/bin/mailq-compatnewaliases /usr/local/supermailer/bin/newaliases-compathoststat /usr/local/supermailer/bin/hoststat-compatpurgestat /usr/local/supermailer/bin/purgestat-compat</pre></div><div class="SECT2"><h2 class="SECT2"><a id="AEN32275" name="AEN32275">22.4.5 Finishing</a></h2><p>Once you have everything configured the way you want it, you should either kill the <bclass="APPLICATION">sendmail</b> processes that you no longer need and start theprocesses belonging to your new software, or simply reboot. Rebooting will also give youthe opportunity to ensure that you have correctly configured your system to start yournew MTA automatically on boot.</p></div></div><div class="NAVFOOTER"><hr align="LEFT" width="100%" /><table summary="Footer navigation table" width="100%" border="0" cellpadding="0"cellspacing="0"><tr><td width="33%" align="left" valign="top"><a href="sendmail.html"accesskey="P">Prev</a></td><td width="34%" align="center" valign="top"><a href="index.html"accesskey="H">Home</a></td><td width="33%" align="right" valign="top"><a href="mail-trouble.html"accesskey="N">Next</a></td></tr><tr><td width="33%" align="left" valign="top"><b class="APPLICATION">sendmail</b>Configuration</td><td width="34%" align="center" valign="top"><a href="mail.html" accesskey="U">Up</a></td><td width="33%" align="right" valign="top">Troubleshooting</td></tr></table></div><p align="center"><small>This, and other documents, can be downloaded from <ahref="ftp://ftp.FreeBSD.org/pub/FreeBSD/doc/">ftp://ftp.FreeBSD.org/pub/FreeBSD/doc/</a>.</small></p><p align="center"><small>For questions about FreeBSD, read the <ahref="http://www.FreeBSD.org/docs.html">documentation</a> before contacting <<ahref="mailto:questions@FreeBSD.org">questions@FreeBSD.org</a>>.<br />For questions about this documentation, e-mail <<ahref="mailto:doc@FreeBSD.org">doc@FreeBSD.org</a>>.</small></p></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -