\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{ ¥»¤å¤¶²Ð®a®x¥Î¤á¼·¸¹³X°Ý¦p¦ó°t¸m sendmail ¡C }


\begin{document}
\maketitle

\section{¾É¨¥}

§Ú­Ì°²³]§A²{¦b¤w¸g¯à°÷¶i¦æÃþ¦ü³q±`¦b¤j¾Ç¤¤ªº¤¬Ápºô³X°Ý¤Î¦b½uªA°È¡G§A¦b¦ê¤fÁp±µ³q¹LPPP¼·¸¹¶i¤J§AªºÁp±µ¨ÑÀ³°Óªººôµ¸¡C
§A±µ¦¬ªº¶l¥ó¬O©ñ¦b¨ÑÀ³°ÓªºPOP©ÎIMAPªA°È¾¹¤¤¡Aµo¥Xªº¶l¥ó«h³q¹LSMTP°e¥X¡C§A¨S¦³¤@­ÓÄÝ¤_§Aªº°ì¦W¡A¦]¦¹¤@¤Á³£¥²¶·¨Ï¥Î{\itshape ¤@­Ó\/}¦a§}¡C



§Ú­Ì°²³]§A¤w¸g¦w¸Ë¤FEric Allmanªºsendmailªº³Ì·sª©¥»(¥»¤å¼g§@®É³Ì·sª©¥»¬O8.8.8¡A³o­Óª©¥»¯à«Ü¦n¦a¤u§@)¡C(Ä¶ªÌ¡G·í«e³Ì·sÃ­©wª©¥»¬O8.9.3)



¥»¤å³¡¤À»¡©ú±M«üDebian GNU/Linux¨t²Î¡A¨Ï¥Î¨ä¥¦µo¦æª©¥»ªº¥Î¤áÀ³¤Þ°_ª`·N¡C



½T»{§A¤âÀY´x´¤¤F¥H¤U«H®§¡G

\begin{itemize}
\item §AªºISPªº¶l¥óªA°È¾¹¡C
\item §Aªº¤¬Ápºô¶l¥ó¦a§}¡C
\end{itemize}






§Ú­Ì­p¦E¤¤ªº°t¸m¥]¬A¨â­Ó¥D­n¥Ø¼Ð¡G

\begin{enumerate}
\item ¯à¦b¨â­Ó¤£¦Pªº¥»¦a¥Î¤á¤§¶¡µo°e¶l¥ó¡C
\item ¥~³¡¥@¬É±µ¦¬¶l¥ó®É¬Ý¨ìªº¬O¥»¦a¥Î¤áªºISPªº¶l¥ó¦a§}¡A¦Ó¤£¬O¥»¦a¶l¥ó¦a§}¡C
\end{enumerate}




¬°¤F¹F¨ì³o­Ó¥Øªº¡A§Ú­Ì±N¨Ï¥Îsendmailªº {\ttfamily genericstable} ¯SÂI¡C




\section{¤å¥ó¸ô®|¬M®g}

§Ú­Ì±N§â©Ò¦³sendmailªº°t¸m¤å¥ó©ñ¦b¥H¤U¤£¦Pªº¥Ø¿ý¤¤¡G {\ttfamily /etc}:
{\ttfamily /etc/mail} ¡C³q±`¡Asendmail±N´Á«Ý³o¨Ç¤å¥ó¦s©ñ¦b {\ttfamily /etc} ¡C 
¬°¤FÁ×§K³o­Ó°ÝÃD¡A±N {\ttfamily /etc/sendmail.cf} ²Å¸¹Ãì±µ¨ì {\ttfamily /etc/mail/sendmail.cf} ¡C



¥H¤U¤å¥ó¦s©ñ¦b {\ttfamily /etc/mail}:
\begin{itemize}
\item =20
\item {\ttfamily aliases} - ¥]§tªþ¥[ªº¥»¦a¦a§}
\item {\ttfamily genericsdomain} - ¥]§t¥»¦a¥D¾÷°t¸mªº¤@¨Ç«H®§
\item {\ttfamily genericstable} - ¥]§t­«¼g³W«h
\item {\ttfamily sendmail.cf} - sendmailªº°t¸m¤å¥ó
\item {\ttfamily sendmail.mc} -  {\ttfamily sendmail.cf} ªº°t¸m·½¥N½X¡C
\end{itemize}


¥H¤W³¡¤À¤å¥ó³£ªþ±aµÛ {\ttfamily .db} ¤å¥ó¡C¥¦­Ì¥]§t¯à³Qsendmailª½±µ¨Ï¥Îªº«¢§Æ¼Æ¾Ú®w¡C



§Ú­Ì°²³]sendmail°t¸m·½¥N½X¾ðªº {\ttfamily cf} ³¡¤À¦s©ñ¦b¥Ø¿ý {\ttfamily /usr/lib/sendmail.cf} ¤¤¡C
¦b Debian GNU/Linux ¨t²Î¤¤´N¬O³o¼Ë¦s©ñªº¡C¨ä¥¦µo¦æª©¥»¥i¯à¦s©ñ¦b¤£¦Pªº¦a¤è¡C¸Ô±¡½Ð°Ñ¦Ò§Aªºµo¦æª©¥»ªº¤åÀÉ¡C




\section{°t¸m sendmail }


\subsection{¥D­nªº°t¸m¤å¥ó}

sendmail ¦b¥¦ªº°t¸m¤¤¨Ï¥Î¬Û·í´_Âøªº³W«h¨t²Î¡C¦b§A´x´¤³\¦h°t¸mÂ¬ªù¤§«e¡A³q¹L¤â¤u¼g¤@­Ó {\ttfamily sendmail.cf} ¤å¥ó«Ü¤£±`¨£¦}¥B¯Ó¶O¤j¶q®É¶¡¡C¦pªG§A¹ï¦¹·P¿³½ì¡A§A¥i¥H°±¤î¾\Åª¥»¤å¦Ó¥h¬Ý O'Reilly ªº "Bat Book" ¡C



¨ú¥N¨Ï¥Î¤â¤u°t¸mªº¤èªk¡A§Ú­Ì¨Ï¥Î {\ttfamily m4} §»³B²z¾¹±N¹w©w¸q¦nªº¤å¥ó¥Í¦¨§Aªº°t¸m¤å¥ó¡A³o¨Ç¹w©w¸q¤å¥óÀH sendmail ªºµo¦æª©¥»¤@¦}´£¨Ñ¡C



½Ð¬Ý¤å¥ó {\ttfamily sendmail.mc} ªº²Ä¤@¦æ¡G

\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}


¦b²Ä¤@¦æ¡A {\ttfamily cf.m4} ³Q¥]§t¶i¨Ó¡C³o­Ó m4 §»¤å¥ó¥]§t¤F¨ä¥¦³¡¤À±N¥Î¨ìªº³\¦h§»©w¸q¡C ½T©w§A´£¨Ñªº¸ô®|¬O¥¿½Tªº ¡Ð 
¦b§Ú­Ì³o­Ó¨Ò¤l¤¤´£¨Ñªº³o­Ó¸ô®|¬ODebian GNU/Linuxªº¨å«¬¸ô®|¡C {\ttfamily OSTYPE} §»³Q¥Î¨Óµ¹¥X¤@¨Ç«D±`¦³¥Îªº·í«e°t¸mªº¯Ê¬Ù­È¡C
¦pªG§A¤£¬O¨Ï¥ÎDebian¨t²Î¡A§A¥i¥H±N³o¨½ªº "debian" ´«¦¨ "linux" ¡C {\ttfamily ALIAS\_FILE} §i¶D sendmail ¨ì­þ¨½¥h§ä¨ì aliases ¤å¥ó¡C



¥H¤U¤L¦æ§i¶D sendmail ¨Ï¥Î {\ttfamily genericstable} ¯SÂI©M¨ì­þ¨½¥h§ä¨ì¨Ï¥Î¸Ó¯SÂIªº°t¸m¤å¥ó¡G
\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} ¯SÂI§i¶D sendmail ¥h¹ê²{¶lÀY­«¼g¨ì¶l¥óªº{\itshape «H«Ê\/} ¶Ç°eªÌ¡C
³o¬O¤@­Ó¥~³¡¶l¥ó§ë»¼¨t²Î±N¥Î¨Óª½±µ§ë»¼¥¢±Ñ³ø§i©MÄµ§i¶l¥óªº¶l¥ó¦a§}¡C{\ttfamily generics*} ¤å¥ó±N¦b¤U­±¸ÑÄÀ¡C



²{¦b¡A§Ú­Ì¥²¶·©w¸q¤@­Ó©Ò¿× smart ¥D¾÷¡A´N¬O±N­n­t³d¬°§Aªº¨t²Î¶Ç°e¥~³¡¶l¥óªº¥D¾÷¡C
ª`·N¡G³o¥x¥D¾÷¦³¥i¯à¤£¬O§AªºISPªºPOP©MIMAPªA°È¾¹¡C ¦pªG¹ï¦¹¤£¤Ó²M·¡¡AÁp¨t§AªºISP¨ÑÀ³°Ó¡C
¥D°t¸m¤å¥óªº¥N½X¦p¤U¡G
\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\/} ¦¨§AªºISPªº¥D¾÷¦a§}¡C



³Ì¦Z¨â¦æ¥]§t "mailer" ©w¸q¡Asendmail ®Ú¾Ú³o¨Ç©w¸q¤~¯àª¾¹D¦p¦ó³B²z¤£¦PÃþ«¬ªº¶l¥ó¡G
\par
\addvspace{\medskipamount}
\nopagebreak\hrule
\begin{verbatim}
MAILER(local)
MAILER(smtp)
\end{verbatim} 
\nopagebreak\hrule 
\addvspace{\medskipamount}




¬°¤F±q³o­Ó {\ttfamily sendmail.mc} ¥Í¦¨ {\ttfamily sendmail.cf} ¤å¥ó¡A¿é¤J¥H¤U©R¥O (§@¬° root ¥Î¤á)¡G
\par
\addvspace{\medskipamount}
\nopagebreak\hrule
\begin{verbatim}
# m4 sendmail.mc > _sendmail.cf
# mv -f _sendmail.cf sendmail.cf
\end{verbatim} 
\nopagebreak\hrule 
\addvspace{\medskipamount}


ª`·N§Ú­Ì¨Ï¥Îªº§Þ¥º¡G±N {\ttfamily m4}  ªº¿é¥X¼g¤J¤@­ÓÁ{®É¤å¥ó¡A¦AÂà²¾¨ì¦X¾Aªº¦a¤è¡C³o±NÀ°§U§Ú­ÌÁ×§KsendmailÅª¤J¥u¼g¤F¤@³¡¤Àªº°t¸m¤å¥ó¡C




\subsection{¦a§}­«¼g}

­º¥ý¡A§Ú­Ì¥²¶·§i¶Dsendmail­þ¨Ç¦a§}±N³Q»{¬°¬O¥»¦a¦a§}(µM¦Z±N³Q­«¼g)¡C³o«ÜÂ²³æ¡G¥u­n±N§Aªº¾÷¾¹ªº§¹¾ã¥D¾÷¦W©ñ¤J¤å¥ó {\ttfamily /etc/mail/genericsdomain}¡C
¬°¤F¨ú±o§Aªº¾÷¾¹ªº§¹¾ã¥D¾÷¦W¡A¿é¤J¥H¤U©R¥O¡G
\par
\addvspace{\medskipamount}
\nopagebreak\hrule
\begin{verbatim}
 $ hostname -f 
\end{verbatim} 
\nopagebreak\hrule 
\addvspace{\medskipamount}




²{¦b¡AÅý§Ú­Ì¬Ý¤@¤U­«¼gªí¡G
{\ttfamily /etc/mail/genericstable} ¡C³o­Ó¤å¥ó¥Ñ³QªÅ®æ¤À¶}ªº¨â¦C²Õ¦¨¡C²Ä¤@¦C¥]§t¥»¦a¦a§}¡A²Ä¤G¦C¥]§t´À´«¦Zªº¶l¥ó¦a§}¡C
¤å¥ó¬Ý°_¨Ó¦p¤U¡G

\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}


ª`·N{\itshape ¨C¤@­Ó\/}¥»¦a¾÷¾¹¤Wªº½ã¸¹³£­n¦³¤@¦æ¡A³o¼Ë¦Û°Ê¥Í¦¨ªº¥~µo¶l¥ó¯à±a¤W¥¿½TªºÀY«H®§¡C 



¬°¤F©Ê¯àªº¦Ò¼{¡A sendmail ¦}¤£ª½±µ¨Ï¥Î³o­Ó¤å¥»¤å¥ó¡A¦Ó¬O¥Î¡§«¢§Æ¡¨ª©¥»´À¥N¡C¬°¤F¥Í¦¨³o­Óª©¥»¡A¿é¤J¥H¤U©R¥O¡G

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




ª`·N¡G {\ttfamily genericstable} «ü©wªº­«¼g³W«h±N{\itshape ¤£\/} §@¥Î¦b¥»¦a¶l¥ó©Î§A±q¥~³¡±µ¦¬¨ìªº¶l¥ó - ³oºØÂà´«¥u¨Ï¥Î¦b±q§A¥»¦a¾÷¾¹³q¹L§AªºISP¥D¾÷µo©¹¥~³¡ªº¶l¥ó¡C




\subsection{§O¦W}

§O¦W¤å¥ó¥]§t¥u¹ï§A¥»¦a¶l¥ó¦³®Äªºªþ¥[¥»¦a¦W¦r¡C³o¹ïºÞ²z­û½ã¸¹¶H {\ttfamily root} «D±`¦³¥Î¡A±q§Aªº¨t²Î±µ¦¬¦Û°ÊÂà´«¨Óªº¶l¥ó¡C



{\ttfamily /etc/mail/aliases} ¥i¯à¦p¤U©Ò¥Ü¡G

\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}


³o­Ó¨Ò¤l±N¸ô¥Ñ°e©¹ {\ttfamily root}, {\ttfamily news}, {\ttfamily postmaster}, {\ttfamily mail}, ©M {\ttfamily www} ¥Î¤áªº¥»¦a¶l¥ó¨ì {\ttfamily fred} ¡A 
¦Ó°e©¹ {\ttfamily nobody} ©M {\ttfamily MAILER-DAEMON} ªº¶l¥ó±N­«©w¦V¨ì {\ttfamily /dev/null} ¡C



´N¶H {\ttfamily genericstable}, {\ttfamily aliases} ¥i¯à¥]§t{\itshape ³\¦h\/} ¶µ¡C¦]¦¹¡A´N¶H§Ú­Ì¤W­±©Ò»¡ªº¡Asendmailª½±µ¨Ï¥Î¤å¥»¤å¥ó±N®Ä²v§C¤U¡C
{\ttfamily aliases} ªö¥Î©M {\ttfamily genericstable}  ¦P¼Ëªº¾÷¨î¡G¥Í¦¨¤@­Ó«¢§Æ¼Æ¾Ú®w¡C
¨ú¥Nª½±µ¨Ï¥Î {\ttfamily makemap} ¡A³o¦¸§A¥i¥H¿é¤J©R¥O {\ttfamily newaliases} ¡C¥¦±N¦Û°Ê³B²z©Ò»Ýªº¤@¤Á¡C




\section{¶i¶¥¾\Åª}

sendmail·½¥N½Xµo¦æª©¤¤¥]§t¤F³\¦h¤åÀÉ¡C¾\Åª¥¦­Ì¡A¯S§O¬O¤å¥ó {\ttfamily cf/README} ¡C



¦pªG§A·Q²`¤J¤F¸Ñsendmailªº°t¸m¿ï¶µ¡A§A¥i¥H±q¥H¤U¦a§}¨ú±o¡§Bat Book¡¨¡G
O'Reilly: Bryan Costales, Eric Allman, and Neil Rickert:
"sendmail".  O'Reilly, 1993.



\end{document}
