📄 mail-procmail.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>Using procmail</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="Using fetchmail" href="mail-fetchmail.html" /><link rel="NEXT" title="Network Servers" href="network-servers.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="mail-fetchmail.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="network-servers.html"accesskey="N">Next</a></td></tr></table><hr align="LEFT" width="100%" /></div><div class="SECT1"><h1 class="SECT1"><a id="MAIL-PROCMAIL" name="MAIL-PROCMAIL">22.13 Usingprocmail</a></h1><i class="AUTHORGROUP"><span class="CONTRIB">Contributed by</span> Marc Silver.</i> <p>The <b class="APPLICATION">procmail</b> utility is an incredibly powerful applicationused to filter incoming mail. It allows users to define ``rules'' which can be matched toincoming mails to perform specific functions or to reroute mail to alternative mailboxesand/or email addresses. <b class="APPLICATION">procmail</b> can be installed using the <ahref="http://www.FreeBSD.org/cgi/url.cgi?ports/mail/procmail/pkg-descr"><ttclass="FILENAME">mail/procmail</tt></a> port. Once installed, it can be directlyintegrated into most <acronym class="ACRONYM">MTA</acronym>s; consult your <acronymclass="ACRONYM">MTA</acronym> documentation for more information. Alternatively, <bclass="APPLICATION">procmail</b> can be integrated by adding the following line to a <ttclass="FILENAME">.forward</tt> in the home directory of the user utilizing <bclass="APPLICATION">procmail</b> features:</p><pre class="PROGRAMLISTING">"|exec /usr/local/bin/procmail || exit 75"</pre><p>The following section will display some basic <b class="APPLICATION">procmail</b>rules, as well as brief descriptions on what they do. These rules, and others must beinserted into a <tt class="FILENAME">.procmailrc</tt> file, which must reside in theuser's home directory.</p><p>The majority of these rules can also be found in the <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=procmailex&sektion=5&manpath=FreeBSD+Ports"><span class="CITEREFENTRY"><span class="REFENTRYTITLE">procmailex</span>(5)</span></a>manual page.</p><p>Forward all mail from <var class="LITERAL">user@example.com</var> to an externaladdress of <var class="LITERAL">goodmail@example2.com</var>:</p><pre class="PROGRAMLISTING">:0* ^From.*user@example.com! goodmail@example2.com</pre><p>Forward all mails shorter than 1000 bytes to an external address of <varclass="LITERAL">goodmail@example2.com</var>:</p><pre class="PROGRAMLISTING">:0* < 1000! goodmail@example2.com</pre><p>Send all mail sent to <var class="LITERAL">alternate@example.com</var> into a mailboxcalled <tt class="FILENAME">alternate</tt>:</p><pre class="PROGRAMLISTING">:0* ^TOalternate@example.comalternate</pre><p>Send all mail with a subject of ``Spam'' to <tt class="FILENAME">/dev/null</tt>:</p><pre class="PROGRAMLISTING">:0^Subject:.*Spam/dev/null</pre><p>A useful recipe that parses incoming <tt class="HOSTID">FreeBSD.org</tt> mailing listsand places each list in its own mailbox:</p><pre class="PROGRAMLISTING">:0* ^Sender:.owner-freebsd-\/[^@]+@FreeBSD.ORG{ LISTNAME=${MATCH} :0 * LISTNAME??^\/[^@]+ FreeBSD-${MATCH}}</pre></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="mail-fetchmail.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="network-servers.html"accesskey="N">Next</a></td></tr><tr><td width="33%" align="left" valign="top">Using fetchmail</td><td width="34%" align="center" valign="top"><a href="mail.html" accesskey="U">Up</a></td><td width="33%" align="right" valign="top">Network Servers</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 + -