sendmail address rewriting mini-HOWTO <author>Thomas Roessler, roessler@guug.de <date>v0.0, 6 May 1998 <trans>高橋 聡 <tt>hisai@din.or.jp</tt> <tdate> 2000/04/19 <!-- <abstract> This document is a brief description of how to set up sendmail's configuration file for the home user's dial-up access. </abstract> --> <abstract> このドキュメントは、自宅からダイヤルアップでアクセスして いる方々を対象に sendmail の簡単な設定方法を説明します。 </abstract> <!-- <sect>Introduction --> <sect>はじめに <!-- <p>We assume that you have the kind of Internet access which seems to be most common at universities and online services nowadays: You dial into your provider's network using PPP over a serial connection. Your incoming mail is spooled at the provider's POP or IMAP server, while outgoing messages are to be sent via SMTP. You don't have a domain name of your own, so everything has to use <em/one/ address. --> <p> このドキュメントでは、大学の設備やオンラインサービスを通じて、最近の主 流と言えそうなありふれた形でインターネットに接続している読者を想定して います。具体的にはこういう方が対象です。 <itemize> <item>接続時はプロバイダにダイヤルしてシリアル回線で PPP 接続している <item>メールはプロバイダの POP サーバか IMAP サーバにスプールされている ものを受信し、SMTP を通じて送信している <item>自前のドメイン名は持っていないため、いつ何時もひとつのアドレスを 使用するしかない </itemize> <!-- <p>We assume that you have already installed a fairly recent version of Eric Allman's sendmail (version 8.8.8 is current at the time of this writing and should work fine). --> <p> 上記に加えて、すでに Eric Allman 氏作成の sendmail の新し目 のバージョンがインストールされているものとします(バージョン 8.8.8 がこのドキュメントを書いている時点での最新版で、問題 なく動作すると思います)。 <!-- <p>This document is partially referring to specific properties of Debian GNU/Linux systems; users of different distributions will have to take some care. --> <p> このドキュメントでは Debian GNU/Linux 独自の構成を例にあげて います。Debian GNU/Linux 以外のディストリビューションを利用 されている場合はご注意ください。 <!-- <p>Make sure you have the following information at hand: --> <p> 下記の情報を事前に調べておいてください。 <itemize> <!-- <item>Your ISP's mail server <item>Your Internet mail address --> <item>加入している ISP のメール・サーバ <item>自分のインターネット上のメール・アドレス </itemize> <!-- <p>The configuration we are planning has two main goals: --> <p> これから行う設定には主に 2 つの目標があります。 <enum> <!-- <item>Sending mail between various local users must be possible. <item>The outside world must see the local users' ISP mail addresses, not the local ones. --> <item>ローカルなユーザ間でメールのやり取りができること <item>外部に対しては、ローカルのメール・アドレスではなく ISP のメール・アドレスを使用すること </enum> <!-- <p>To achieve this, we will make use of sendmail's <tt/genericstable/ feature. --> <p> sendmail の機能の 1 つである <tt/genericstable/ を 使うことによって、この目標を達成することができる ようになります。 <!-- <sect>File Roadmap --> <sect>設定ファイルの構成 <!-- <p>We will put all of sendmail's configuration files in a separate directory under <tt//etc/: <tt//etc/mail/. Usually, sendmail will expect these files to reside directly under <tt//etc/. To avoid problems, <tt//etc/sendmail.cf/ should be a symbolic link to <tt//etc/mail/sendmail.cf/. --> <p> まず <tt//etc/ にある sendmail 関連の設定ファイルすべてを <tt//etc/mail/ に移動して、他の設定ファイルと分けま しょう。sendmail はこれらのファイルが <tt//etc/ にある ものと仮定していますので、問題が生じないように <tt//etc/sendmail.cf/ は <tt//etc/mail/sendmail.cf/ にシンボリック・リンク を張っておきましょう。 <!-- <p>The following files will populate <tt//etc/mail/: --> <p> 下記のファイルが <tt//etc/mail/ に存在していると思います。 <itemize> <!-- </itemize><itemize>=20 <item><tt/aliases/ - contains additional local addresses <item><tt/genericsdomain/ - contains some information on your local host's configuration <item><tt/genericstable/ - contains the actual rewriting rules. <item><tt/sendmail.cf/ - sendmail's configuration file <item><tt/sendmail.mc/ - the source of <tt/sendmail.cf/. --> <item><tt/aliases/ - ローカルで使用されるアドレスが書かれている <item><tt/genericsdomain/ - ローカルに接続されているホストの設定 情報が書かれている <item><tt/genericstable/ - アドレスを書き換えるルールが書かれて いる <item><tt/sendmail.cf/ - sendmail の設定が書かれている <item><tt/sendmail.mc/ - <tt/sendmail.cf/ のソース </itemize> <!-- Some of these files will be accompanied by <tt/.db/ files. They contain hashed databases for sendmail's direct use. --> これらのファイルの内 <tt/.db/ ファイルを合わせて持っているもの もあります。これらはハッシュされているデータベースで、sendmail は 直接こちらを参照します。 <!-- <p>We assume that the <tt/cf/ part of sendmail's source tree resides under a directory named <tt//usr/lib/sendmail.cf/. This is the case on Debian GNU/Linux systems. Other distributions will put this stuff at different places. Please refer to your distribution's documentation for details. --> <p> sendmail の <tt/cf/ 関連のソース・ツリーが <tt//usr/lib/sendmail.cf/ にあるものとします。 これは Debian GNU/Linux の場合です。他のディストリビューション では違う所にあるかもしれないので、ディストリビューション付属の 資料を読んで詳細を確認してください。 <!-- <sect>Configuring sendmail <sect1>The main configuration file --> <sect>sendmail の設定 <sect1>主な設定ファイル <!-- <p>Sendmail uses a highly complex rule system for it's configuration. While you can do lots of neat tricks with this stuff, writing a <tt/sendmail.cf/ file from scratch is rather unusual and time-consuming. If you are interested in doing so, you should stop reading this document right now and instead read the "Bat Book" from O'Reilly. --> <p> sendmail の設定には、とても複雑なルールを使用する必要があります。 それだけいろいろ工夫をこらした設定を行うことが可能ですが、普通は 一から<tt/sendmail.cf/ を書くようなことは行いません。それは時間 の無駄です。書き上げること自体に興味を持っているなら、このドキュ メントを読むことを即刻止めて、かわりに O'Reilly から出版されている 「コウモリ本」を読むことをお薦めします。 <!-- <p>Instead of hand-crafting these rules, we will rely on the <tt/m4/ macro processor to put together our configuration file from ready-made pieces which are distributed together with sendmail. --> <p> これらのルールを手書きするかわりに、<tt/m4/ マクロ・プロセッサ のお世話になることにしましょう。そうすれば sendmail 付属の雛形 のファイルから設定ファイルを生成できます。 <!-- <p>Let's look at the first lines of the <tt/sendmail.mc/ file: --> <p> まず <tt/sendmail.mc/ ファイルのはじめの部分を見ましょう。 <code> include(/usr/lib/sendmail.cf/m4/cf.m4) VERSIONID(`sendmail.mc - roessler@guug.de') OSTYPE(debian) define(`ALIAS_FILE',`/etc/mail/aliases') </code> <!-- In the beginning, <tt/cf.m4/ is included. This m4 macro file contains lots of macro definitions for the rest of the file. Be sure that the path you give here is correct - the one we are representing in our example is typical for Debian GNU/Linux. The <tt/OSTYPE/ macro is used to give some useful defaults for certain configuration values. If you aren't using a Debian system, you should replace the word "debian" by "linux" here. <tt/ALIAS_FILE/ tells sendmail where to look for the list of aliases. --> 最初に <tt/cf.m4/ を include しています。この m4 マクロの ファイルにはこの後で利用することになるマクロが数多く定義 されています。指定しているパスが正しいかチェックしてくだ さい。なおここであげているのは、Debian GNU/Linux での例 です。<tt/OSTYPE/ はいろいろなデフォルトの設定値をセット するのに便利なマクロです。Debian を使っていないなら、 「debian」を「linux」に置き換えてください。<tt/ALIAS_FILE/ によって sendmail が参照するエイリアスのリストを決めています。 <!-- <p>The following lines tell sendmail to use the <tt/genericstable/ feature, and where to find the configuration files needed to use it: <code> FEATURE(masquerade_envelope) FEATURE(genericstable, `hash -o /etc/mail/genericstable') GENERICS_DOMAIN_FILE(`/etc/mail/genericsdomain') </code> The <tt/masquerade_envelope/ feature tells sendmail to apply header rewriting to the <em/envelope/ sender of a message. This is the mail address to which external mail delivery subsystems will direct their delivery failure reports and warning messages. The <tt/generics*/ files will be explained below. --> <p> 下記の行は sendmail の機能である <tt/genericstable/ を 使用する指定しています。またそれを使用するために必要な 設定ファイルがどこにあるのかも指定しています。 <code> FEATURE(masquerade_envelope) FEATURE(genericstable, `hash -o /etc/mail/genericstable') GENERICS_DOMAIN_FILE(`/etc/mail/genericsdomain') </code> <tt/masquerade_envelope/ 機能は、sendmail がメッセージに 書かれているエンベロープの送信者(Sender)の部分を書き換え ます。外部のメール配送システムがメールを配送できなかった 場合や、何らかの警告メッセージを送信者に知らせる場合に このアドレスを使用します。<tt/generics*/ ファイルについて は後で説明します。 <!-- <p>Now, we have to define a so-called smart host, that is, a machine which will handle outgoing mail for your system. Note that this machine may be different from your ISP's POP and IMAP servers. If in doubt, contact the hotline. The code in the master configuration file: --> <p> それではここで、スマートホストと呼ばれている、外部にメールを 配送する役目を負うマシンについて説明しておきましょう。 このマシンが ISP の POP、IMAP サーバとは違う役割を果たして いるということに注意してください。本当かな、とお思いなら、 ISP に電話して聞いてみてください。主な設定ファイルの内容 は下記の通りです。 <code> define(`SMART_HOST',`mail-out.your.provider') </code> <!-- Please replace <em/mail-out.your.provider/ by the fully qualified hostname of your internet service provider. --> <em/mail-out.your.provider/ の部分を ISP のホスト名に 置き換えてください。この名前はインターネット上で一意に 識別できる名前である必要があります。 <!-- <p>The final two lines include the "mailer" definitions which are needed by sendmail to find out how to handle various types of mail: --> <p> 「mailer」の記述がある最後の 2 行は sendmail がいろいろ な種類のメールをどのように処理するかを決定するために必要 です。 <code> MAILER(local) MAILER(smtp) </code> <!-- <p>To generate the <tt/sendmail.cf/ file from this <tt/sendmail.mc/, type the following commands (as root): --> <p> この <tt/sendmail.mc/ から <tt/sendmail.cf/ を生成するには、 下記のコマンドを root で実行してください。 <code> # m4 sendmail.mc > _sendmail.cf # mv -f _sendmail.cf sendmail.cf </code> <!-- Note the technique of writing <tt/m4/'s output to a temporary file which is thereafter moved to the proper place. This helps us to prevent sendmail from reading partially written configuration files. --> <tt/m4/ による処理結果をテンポラリファイルにいったん 書いてから、正式の名前に変更してください。こうすることに よって、sendmail がまだきちんと設定していないファイルを 使用してしまうことを防ぐことができます。 <!-- <sect1>Address rewriting --> <sect1>アドレスの書き換え <!-- <p>First, we have to tell sendmail what addresses are to be considered local (and thus should be subjected to the rewriting). This is quite simple: Just put the fully qualified host name of your machine into the file <tt//etc/mail/genericsdomain/. To get your host's fully qualified name, type the following command: --> <p> まず sendmail にどれがローカルなアドレス(つまり書き換えの対象 になる)なのかを判断させる必要があります。 このやり方はとても単純です。マシンについているインターネット で一意に識別できるホスト名を <tt//etc/mail/genericsdomain/ に書くだけです。 そのホスト名を調べるには下記のコマンドを入力してください。 <code> $ hostname -f </code> <!-- <p>Now, let's come to the rewriting table proper: <tt//etc/mail/genericstable/. This file consists of two white-space separated columns. The first column contains the local address, the second column contains the e-mail address which should be used instead. The file may look like this: --> <p> それではアドレスの書き換え方を決めるテーブルである <tt//etc/mail/genericstable/をきちんと書いてみ ましょう。このファイルは、スペースで区切られた 2 つのカラム から構成されています。左側のカラムがローカルで使われるアド レスで、右側がその代わりに使用されるアドレスです。 下記のような形になります。 <code> harry harryx@your.isp maude maudey@her.isp root fredx@your.isp news fredx@your.isp </code> <!-- Note that there should be one entry for <em/each/ account on the local machine, so that automatically generated mail which leaks out of the local system carries correct header information. --> 1 つの指定ごとにローカルにあるマシンの<em>それぞれの</em> アカウントを指定してください。そうするとローカルなシステム から自動的に出されたメールに正しいヘッダー情報がつけられる ことになります。 <!-- <p>For performance reasons, sendmail won't use this text file directly, but rely on a "hashed" version instead. To generate it, type the following command: --> <p> パフォーマンスを上げるため、sendmail はテキストで書かれたこの ファイルを直接利用しません。その代わりに「ハッシュ済み」のファイル を使います。そのファイルを作るには、下記の通りに入力します。 <code> # makemap -r hash genericstable.db < genericstable </code> <!-- <p>Note that the rewriting rules from the <tt/genericstable/ will <em/not/ apply to local mail or to messages you receive from outside - the mapping is only used if a message leaves your local system for your ISP's smart host. --> <p> <tt/genericstable/ にある書き換えのルールはローカルでのやり 取りや外部から配送されるメールには適用<em>されません</em>。 この書き換えはローカルなシステムから ISP のスマートホスト に送る場合にだけ行われます。 <sect1>Aliases <!-- <p>The aliases file contains additional local names which are only valid for local messages. This is useful for administrative accounts like <tt/root/ which receive automatically generated messages from your system. --> <p> aliases ファイルには、ローカルでやりとりするメールが使用する 名前を定義してあります。<tt/root/ のように、自動的にシステム からのメールを送られる、何かを管理するためのアカウントにとっ ては便利な機能です。 <!-- <p>A reasonable start for <tt//etc/mail/aliases/ could look like the following file: --> <p> <tt//etc/mail/aliases/ の正しい例は下記のような 内容のファイルになるでしょう。 <code> root: fred news: root postmaster: root mail: root www: root nobody: /dev/null MAILER-DAEMON: nobody </code> <!-- This example will forward local mail for the <tt/root/, <tt/news/, <tt/postmaster/, <tt/mail/, and <tt/www/ users to <tt/fred/, while messages for <tt/nobody/ and <tt/MAILER-DAEMON/ will be redirected to <tt//dev/null/. --> <p> この例ですと、<tt/root/、<tt/news/、<tt/postmaster/、<tt/mail/、 <tt/www/ ユーザ宛のメールは <tt/fred/ に送られ、<tt/nobody/ と <tt/MAILER-DAEMON/ 宛のメールは <tt//dev/null/ 行きに なります。 <!-- <p>Just like the <tt/genericstable/, <tt/aliases/ may contain <em/lots/ of entries. Thus, it would once again be inefficient for sendmail to use the text file we just described. The same mechanism as with <tt/genericstable/ is used for <tt/aliases/: A hashed database is generated. Instead of using <tt/makemap/ directly, you can type in the command <tt/newaliases/ this time. It will automatically take care of all what's needed. --> <p> <tt/aliases/ は <tt/genericstable/ と同様に<em>多くの </em>エントリを含みます。したがって、genericstable と同じ 理由で sendmail がこのファイルをテキストで扱うのは得策では ありません。<tt/genericstable/ と同じ仕組みである ハッシュ されたデータベースが <tt/aliases/ にも利用されています。 ただ <tt/makemap/ を直接使用せずに、<tt/newaliases/ という コマンドを使ってもかまいません。このコマンドが必要な処理を すべて自動的に行ってくれます。 <!-- <sect>Further reading --> <sect>さらに知りたい場合は <!-- <p>The sendmail source distribution includes quite a bit of documentation. Read it, especially the file <tt/cf/README/. --> <p> sendmail のソースには、ドキュメントがかなりたくさんついて います。まずこれを読んでみてください。特に <tt/cf/README/ を。 <!-- <p>If you are interested to dive deeper into sendmail's configuration options, you want to get the "Bat Book" from O'Reilly: Bryan Costales, Eric Allman, and Neil Rickert: "sendmail". O'Reilly, 1993. --> <p> sendmail の設定方法を深く究めたいならば、「コウモリ本」と 呼ばれている O'Reilly Bryan Costales, Eric Allman, and Neil Rickert: "sendmail". O'Reilly, 1993 を読んでください。<newline> <em>訳註:</em>日本語版として、 村井純 監訳、鈴木克彦 訳:『sendmail 解説』(インタ−ナショナル・トムソン ・パブリッシング・ジャパン、1994)があります。 <sect>日本語版謝辞 <p> 翻訳を行うに当たって下記の方々にお世話になりました。ありがとう ございました。 <itemize> <item>高城@長野高専 さん <item>山下義之 さん </itemize> </article></linuxdoc>