\documentclass[letterpaper]{article}
\nonstopmode
\akai
\usepackage{linuxdoc-sgml}
\usepackage{qwertz}
\usepackage{url}
\usepackage[latin1]{inputenc}
\usepackage{t1enc}
\usepackage[english]{babel}
\usepackage{epsfig}
\usepackage{null}
\def\addbibtoc{
\addcontentsline{toc}{section}{\numberline{\mbox{}}\relax\bibname}
}%end-preamble
\setcounter{page}{1}
\title{sendmail address rewriting mini-HOWTO}
\author{×÷Õß: Thomas Roessler {\ttfamily \onlynameurl{roessler@guug.de}}\\ 
ÒëÕß: ËÕ½­ÎÄ {\ttfamily \onlynameurl{softsprite@yeah.net}}}
\date{v0.0, 6 May 1998
·­ÒëÈÕÆÚ: 16 Dec 1999}
\abstract{ ±¾ÎÄ½éÉÜ¼ÒÍ¥ÓÃ»§²¦ºÅ·ÃÎÊÈçºÎÅäÖÃ sendmail ¡£ }


\begin{document}
\maketitle

\section{µ¼ÑÔ}

ÎÒÃÇ¼ÙÉèÄãÏÖÔÚÒÑ¾­ÄÜ¹»½øÐÐÀàËÆÍ¨³£ÔÚ´óÑ§ÖÐµÄ»¥ÁªÍø·ÃÎÊ¼°ÔÚÏß·þÎñ£ºÄãÔÚ´®¿ÚÁª½ÓÍ¨¹ýPPP²¦ºÅ½øÈëÄãµÄÁª½Ó¹©Ó¦ÉÌµÄÍøÂç¡£
Äã½ÓÊÕµÄÓÊ¼þÊÇ·ÅÔÚ¹©Ó¦ÉÌµÄPOP»òIMAP·þÎñÆ÷ÖÐ£¬·¢³öµÄÓÊ¼þÔòÍ¨¹ýSMTPËÍ³ö¡£ÄãÃ»ÓÐÒ»¸öÊôÓÚÄãµÄÓòÃû£¬Òò´ËÒ»ÇÐ¶¼±ØÐëÊ¹ÓÃ{\itshape Ò»¸ö\/}µØÖ·¡£



ÎÒÃÇ¼ÙÉèÄãÒÑ¾­°²×°ÁËEric AllmanµÄsendmailµÄ×îÐÂ°æ±¾(±¾ÎÄÐ´×÷Ê±×îÐÂ°æ±¾ÊÇ8.8.8£¬Õâ¸ö°æ±¾ÄÜºÜºÃµØ¹¤×÷)¡£(ÒëÕß£ºµ±Ç°×îÐÂÎÈ¶¨°æ±¾ÊÇ8.9.3)



±¾ÎÄ²¿·ÖËµÃ÷×¨Ö¸Debian GNU/LinuxÏµÍ³£¬Ê¹ÓÃÆäËü·¢ÐÐ°æ±¾µÄÓÃ»§Ó¦ÒýÆð×¢Òâ¡£



È·ÈÏÄãÊÖÍ·ÕÆÎÕÁËÒÔÏÂÐÅÏ¢£º

\begin{itemize}
\item ÄãµÄISPµÄÓÊ¼þ·þÎñÆ÷¡£
\item ÄãµÄ»¥ÁªÍøÓÊ¼þµØÖ·¡£
\end{itemize}






ÎÒÃÇ¼Æ»®ÖÐµÄÅäÖÃ°üÀ¨Á½¸öÖ÷ÒªÄ¿±ê£º

\begin{enumerate}
\item ÄÜÔÚÁ½¸ö²»Í¬µÄ±¾µØÓÃ»§Ö®¼ä·¢ËÍÓÊ¼þ¡£
\item Íâ²¿ÊÀ½ç½ÓÊÕÓÊ¼þÊ±¿´µ½µÄÊÇ±¾µØÓÃ»§µÄISPµÄÓÊ¼þµØÖ·£¬¶ø²»ÊÇ±¾µØÓÊ¼þµØÖ·¡£
\end{enumerate}




ÎªÁË´ïµ½Õâ¸öÄ¿µÄ£¬ÎÒÃÇ½«Ê¹ÓÃsendmailµÄ {\ttfamily genericstable} ÌØµã¡£




\section{ÎÄ¼þÂ·¾¶Ó³Éä}

ÎÒÃÇ½«°ÑËùÓÐsendmailµÄÅäÖÃÎÄ¼þ·ÅÔÚÒÔÏÂ²»Í¬µÄÄ¿Â¼ÖÐ£º {\ttfamily /etc}:
{\ttfamily /etc/mail} ¡£Í¨³££¬sendmail½«ÆÚ´ýÕâÐ©ÎÄ¼þ´æ·ÅÔÚ {\ttfamily /etc} ¡£ 
ÎªÁË±ÜÃâÕâ¸öÎÊÌâ£¬½« {\ttfamily /etc/sendmail.cf} ·ûºÅÁ´½Óµ½ {\ttfamily /etc/mail/sendmail.cf} ¡£



ÒÔÏÂÎÄ¼þ´æ·ÅÔÚ {\ttfamily /etc/mail}:
\begin{itemize}
\item =20
\item {\ttfamily aliases} - °üº¬¸½¼ÓµÄ±¾µØµØÖ·
\item {\ttfamily genericsdomain} - °üº¬±¾µØÖ÷»úÅäÖÃµÄÒ»Ð©ÐÅÏ¢
\item {\ttfamily genericstable} - °üº¬ÖØÐ´¹æÔò
\item {\ttfamily sendmail.cf} - sendmailµÄÅäÖÃÎÄ¼þ
\item {\ttfamily sendmail.mc} -  {\ttfamily sendmail.cf} µÄÅäÖÃÔ´´úÂë¡£
\end{itemize}


ÒÔÉÏ²¿·ÖÎÄ¼þ¶¼¸½´øÖø {\ttfamily .db} ÎÄ¼þ¡£ËüÃÇ°üº¬ÄÜ±»sendmailÖ±½ÓÊ¹ÓÃµÄ¹þÏ£Êý¾Ý¿â¡£



ÎÒÃÇ¼ÙÉèsendmailÅäÖÃÔ´´úÂëÊ÷µÄ {\ttfamily cf} ²¿·Ö´æ·ÅÔÚÄ¿Â¼ {\ttfamily /usr/lib/sendmail.cf} ÖÐ¡£
ÔÚ Debian GNU/Linux ÏµÍ³ÖÐ¾ÍÊÇÕâÑù´æ·ÅµÄ¡£ÆäËü·¢ÐÐ°æ±¾¿ÉÄÜ´æ·ÅÔÚ²»Í¬µÄµØ·½¡£ÏêÇéÇë²Î¿¼ÄãµÄ·¢ÐÐ°æ±¾µÄÎÄµµ¡£




\section{ÅäÖÃ sendmail }


\subsection{Ö÷ÒªµÄÅäÖÃÎÄ¼þ}

sendmail ÔÚËüµÄÅäÖÃÖÐÊ¹ÓÃÏàµ±¸´ÔÓµÄ¹æÔòÏµÍ³¡£ÔÚÄãÕÆÎÕÐí¶àÅäÖÃÇÏÃÅÖ®Ç°£¬Í¨¹ýÊÖ¹¤Ð´Ò»¸ö {\ttfamily sendmail.cf} ÎÄ¼þºÜ²»³£¼û²¢ÇÒºÄ·Ñ´óÁ¿Ê±¼ä¡£Èç¹ûÄã¶Ô´Ë¸ÐÐËÈ¤£¬Äã¿ÉÒÔÍ£Ö¹ÔÄ¶Á±¾ÎÄ¶øÈ¥¿´ O'Reilly µÄ "Bat Book" ¡£



È¡´úÊ¹ÓÃÊÖ¹¤ÅäÖÃµÄ·½·¨£¬ÎÒÃÇÊ¹ÓÃ {\ttfamily m4} ºê´¦ÀíÆ÷½«Ô¤¶¨ÒåºÃµÄÎÄ¼þÉú³ÉÄãµÄÅäÖÃÎÄ¼þ£¬ÕâÐ©Ô¤¶¨ÒåÎÄ¼þËæ sendmail µÄ·¢ÐÐ°æ±¾Ò»²¢Ìá¹©¡£



Çë¿´ÎÄ¼þ {\ttfamily sendmail.mc} µÄµÚÒ»ÐÐ£º

\par
\addvspace{\medskipamount}
\nopagebreak\hrule
\begin{verbatim}
include(/usr/lib/sendmail.cf/m4/cf.m4)
VERSIONID(`sendmail.mc - roessler@guug.de')
OSTYPE(debian)
define(`ALIAS_FILE',`/etc/mail/aliases')
\end{verbatim} 
\nopagebreak\hrule 
\addvspace{\medskipamount}


ÔÚµÚÒ»ÐÐ£¬ {\ttfamily cf.m4} ±»°üº¬½øÀ´¡£Õâ¸ö m4 ºêÎÄ¼þ°üº¬ÁËÆäËü²¿·Ö½«ÓÃµ½µÄÐí¶àºê¶¨Òå¡£ È·¶¨ÄãÌá¹©µÄÂ·¾¶ÊÇÕýÈ·µÄ £­ 
ÔÚÎÒÃÇÕâ¸öÀý×ÓÖÐÌá¹©µÄÕâ¸öÂ·¾¶ÊÇDebian GNU/LinuxµÄµäÐÍÂ·¾¶¡£ {\ttfamily OSTYPE} ºê±»ÓÃÀ´¸ø³öÒ»Ð©·Ç³£ÓÐÓÃµÄµ±Ç°ÅäÖÃµÄÈ±Ê¡Öµ¡£
Èç¹ûÄã²»ÊÇÊ¹ÓÃDebianÏµÍ³£¬Äã¿ÉÒÔ½«ÕâÀïµÄ "debian" »»³É "linux" ¡£ {\ttfamily ALIAS\_FILE} ¸æËß sendmail µ½ÄÄÀïÈ¥ÕÒµ½ aliases ÎÄ¼þ¡£



ÒÔÏÂ¼¸ÐÐ¸æËß sendmail Ê¹ÓÃ {\ttfamily genericstable} ÌØµãºÍµ½ÄÄÀïÈ¥ÕÒµ½Ê¹ÓÃ¸ÃÌØµãµÄÅäÖÃÎÄ¼þ£º
\par
\addvspace{\medskipamount}
\nopagebreak\hrule
\begin{verbatim}
FEATURE(masquerade_envelope) FEATURE(genericstable, `hash
-o /etc/mail/genericstable')
GENERICS_DOMAIN_FILE(`/etc/mail/genericsdomain') 
\end{verbatim} 
\nopagebreak\hrule 
\addvspace{\medskipamount}


{\ttfamily masquerade\_envelope} ÌØµã¸æËß sendmail È¥ÊµÏÖÓÊÍ·ÖØÐ´µ½ÓÊ¼þµÄ{\itshape ÐÅ·â\/} ´«ËÍÕß¡£
ÕâÊÇÒ»¸öÍâ²¿ÓÊ¼þÍ¶µÝÏµÍ³½«ÓÃÀ´Ö±½ÓÍ¶µÝÊ§°Ü±¨¸æºÍ¾¯¸æÓÊ¼þµÄÓÊ¼þµØÖ·¡£{\ttfamily generics*} ÎÄ¼þ½«ÔÚÏÂÃæ½âÊÍ¡£



ÏÖÔÚ£¬ÎÒÃÇ±ØÐë¶¨ÒåÒ»¸öËùÎ½ smart Ö÷»ú£¬¾ÍÊÇ½«Òª¸ºÔðÎªÄãµÄÏµÍ³´«ËÍÍâ²¿ÓÊ¼þµÄÖ÷»ú¡£
×¢Òâ£ºÕâÌ¨Ö÷»úÓÐ¿ÉÄÜ²»ÊÇÄãµÄISPµÄPOPºÍIMAP·þÎñÆ÷¡£ Èç¹û¶Ô´Ë²»Ì«Çå³þ£¬ÁªÏµÄãµÄISP¹©Ó¦ÉÌ¡£
Ö÷ÅäÖÃÎÄ¼þµÄ´úÂëÈçÏÂ£º
\par
\addvspace{\medskipamount}
\nopagebreak\hrule
\begin{verbatim}
define(`SMART_HOST',`mail-out.your.provider')
\end{verbatim} 
\nopagebreak\hrule 
\addvspace{\medskipamount}


ÇëÌæ»» {\itshape mail-out.your.provider\/} ³ÉÄãµÄISPµÄÖ÷»úµØÖ·¡£



×îºóÁ½ÐÐ°üº¬ "mailer" ¶¨Òå£¬sendmail ¸ù¾ÝÕâÐ©¶¨Òå²ÅÄÜÖªµÀÈçºÎ´¦Àí²»Í¬ÀàÐÍµÄÓÊ¼þ£º
\par
\addvspace{\medskipamount}
\nopagebreak\hrule
\begin{verbatim}
MAILER(local)
MAILER(smtp)
\end{verbatim} 
\nopagebreak\hrule 
\addvspace{\medskipamount}




ÎªÁË´ÓÕâ¸ö {\ttfamily sendmail.mc} Éú³É {\ttfamily sendmail.cf} ÎÄ¼þ£¬ÊäÈëÒÔÏÂÃüÁî (×÷Îª root ÓÃ»§)£º
\par
\addvspace{\medskipamount}
\nopagebreak\hrule
\begin{verbatim}
# m4 sendmail.mc > _sendmail.cf
# mv -f _sendmail.cf sendmail.cf
\end{verbatim} 
\nopagebreak\hrule 
\addvspace{\medskipamount}


×¢ÒâÎÒÃÇÊ¹ÓÃµÄ¼¼Êõ£º½« {\ttfamily m4}  µÄÊä³öÐ´ÈëÒ»¸öÁÙÊ±ÎÄ¼þ£¬ÔÙ×ªÒÆµ½ºÏÊÊµÄµØ·½¡£Õâ½«°ïÖúÎÒÃÇ±ÜÃâsendmail¶ÁÈëÖ»Ð´ÁËÒ»²¿·ÖµÄÅäÖÃÎÄ¼þ¡£




\subsection{µØÖ·ÖØÐ´}

Ê×ÏÈ£¬ÎÒÃÇ±ØÐë¸æËßsendmailÄÄÐ©µØÖ·½«±»ÈÏÎªÊÇ±¾µØµØÖ·(È»ºó½«±»ÖØÐ´)¡£ÕâºÜ¼òµ¥£ºÖ»Òª½«ÄãµÄ»úÆ÷µÄÍêÕûÖ÷»úÃû·ÅÈëÎÄ¼þ {\ttfamily /etc/mail/genericsdomain}¡£
ÎªÁËÈ¡µÃÄãµÄ»úÆ÷µÄÍêÕûÖ÷»úÃû£¬ÊäÈëÒÔÏÂÃüÁî£º
\par
\addvspace{\medskipamount}
\nopagebreak\hrule
\begin{verbatim}
 $ hostname -f 
\end{verbatim} 
\nopagebreak\hrule 
\addvspace{\medskipamount}




ÏÖÔÚ£¬ÈÃÎÒÃÇ¿´Ò»ÏÂÖØÐ´±í£º
{\ttfamily /etc/mail/genericstable} ¡£Õâ¸öÎÄ¼þÓÉ±»¿Õ¸ñ·Ö¿ªµÄÁ½ÁÐ×é³É¡£µÚÒ»ÁÐ°üº¬±¾µØµØÖ·£¬µÚ¶þÁÐ°üº¬Ìæ»»ºóµÄÓÊ¼þµØÖ·¡£
ÎÄ¼þ¿´ÆðÀ´ÈçÏÂ£º

\par
\addvspace{\medskipamount}
\nopagebreak\hrule
\begin{verbatim}
harry   harryx@your.isp
maude   maudey@her.isp
root    fredx@your.isp
news    fredx@your.isp
\end{verbatim} 
\nopagebreak\hrule 
\addvspace{\medskipamount}


×¢Òâ{\itshape Ã¿Ò»¸ö\/}±¾µØ»úÆ÷ÉÏµÄÕËºÅ¶¼ÒªÓÐÒ»ÐÐ£¬ÕâÑù×Ô¶¯Éú³ÉµÄÍâ·¢ÓÊ¼þÄÜ´øÉÏÕýÈ·µÄÍ·ÐÅÏ¢¡£ 



ÎªÁËÐÔÄÜµÄ¿¼ÂÇ£¬ sendmail ²¢²»Ö±½ÓÊ¹ÓÃÕâ¸öÎÄ±¾ÎÄ¼þ£¬¶øÊÇÓÃ¡°¹þÏ£¡±°æ±¾Ìæ´ú¡£ÎªÁËÉú³ÉÕâ¸ö°æ±¾£¬ÊäÈëÒÔÏÂÃüÁî£º

\par
\addvspace{\medskipamount}
\nopagebreak\hrule
\begin{verbatim}
# makemap -r hash genericstable.db < genericstable
\end{verbatim} 
\nopagebreak\hrule 
\addvspace{\medskipamount}




×¢Òâ£º {\ttfamily genericstable} Ö¸¶¨µÄÖØÐ´¹æÔò½«{\itshape ²»\/} ×÷ÓÃÔÚ±¾µØÓÊ¼þ»òÄã´ÓÍâ²¿½ÓÊÕµ½µÄÓÊ¼þ - ÕâÖÖ×ª»»Ö»Ê¹ÓÃÔÚ´ÓÄã±¾µØ»úÆ÷Í¨¹ýÄãµÄISPÖ÷»ú·¢ÍùÍâ²¿µÄÓÊ¼þ¡£




\subsection{±ðÃû}

±ðÃûÎÄ¼þ°üº¬Ö»¶ÔÄã±¾µØÓÊ¼þÓÐÐ§µÄ¸½¼Ó±¾µØÃû×Ö¡£Õâ¶Ô¹ÜÀíÔ±ÕËºÅÏó {\ttfamily root} ·Ç³£ÓÐÓÃ£¬´ÓÄãµÄÏµÍ³½ÓÊÕ×Ô¶¯×ª»»À´µÄÓÊ¼þ¡£



{\ttfamily /etc/mail/aliases} ¿ÉÄÜÈçÏÂËùÊ¾£º

\par
\addvspace{\medskipamount}
\nopagebreak\hrule
\begin{verbatim}
root: fred
news: root
postmaster: root
mail: root
www: root

nobody: /dev/null
MAILER-DAEMON: nobody
\end{verbatim} 
\nopagebreak\hrule 
\addvspace{\medskipamount}


Õâ¸öÀý×Ó½«Â·ÓÉËÍÍù {\ttfamily root}, {\ttfamily news}, {\ttfamily postmaster}, {\ttfamily mail}, ºÍ {\ttfamily www} ÓÃ»§µÄ±¾µØÓÊ¼þµ½ {\ttfamily fred} £¬ 
¶øËÍÍù {\ttfamily nobody} ºÍ {\ttfamily MAILER-DAEMON} µÄÓÊ¼þ½«ÖØ¶¨Ïòµ½ {\ttfamily /dev/null} ¡£



¾ÍÏó {\ttfamily genericstable}, {\ttfamily aliases} ¿ÉÄÜ°üº¬{\itshape Ðí¶à\/} Ïî¡£Òò´Ë£¬¾ÍÏóÎÒÃÇÉÏÃæËùËµµÄ£¬sendmailÖ±½ÓÊ¹ÓÃÎÄ±¾ÎÄ¼þ½«Ð§ÂÊµÍÏÂ¡£
{\ttfamily aliases} ²ÉÓÃºÍ {\ttfamily genericstable}  Í¬ÑùµÄ»úÖÆ£ºÉú³ÉÒ»¸ö¹þÏ£Êý¾Ý¿â¡£
È¡´úÖ±½ÓÊ¹ÓÃ {\ttfamily makemap} £¬Õâ´ÎÄã¿ÉÒÔÊäÈëÃüÁî {\ttfamily newaliases} ¡£Ëü½«×Ô¶¯´¦ÀíËùÐèµÄÒ»ÇÐ¡£




\section{½ø½×ÔÄ¶Á}

sendmailÔ´´úÂë·¢ÐÐ°æÖÐ°üº¬ÁËÐí¶àÎÄµµ¡£ÔÄ¶ÁËüÃÇ£¬ÌØ±ðÊÇÎÄ¼þ {\ttfamily cf/README} ¡£



Èç¹ûÄãÏëÉîÈëÁË½âsendmailµÄÅäÖÃÑ¡Ïî£¬Äã¿ÉÒÔ´ÓÒÔÏÂµØÖ·È¡µÃ¡°Bat Book¡±£º
O'Reilly: Bryan Costales, Eric Allman, and Neil Rickert:
"sendmail".  O'Reilly, 1993.



\end{document}
