diff options
| author | fukachan <fukachan> | 2006-01-14 06:04:48 +0000 |
|---|---|---|
| committer | fukachan <fukachan> | 2006-01-14 06:04:48 +0000 |
| commit | f682fe460ea9cfdf8a17e6f785ce631d8a5c69b1 (patch) | |
| tree | 5642271e869a6bd0aa275bd6949705a03ff9fccb /fml | |
| parent | e84177d180e7fe481ca3708e28d40eabcd1e8739 (diff) | |
| parent | 1e6ac97d07c3075f91cf1f0f8cdd6ff6bd8cb57e (diff) | |
| download | fml8-f682fe460ea9cfdf8a17e6f785ce631d8a5c69b1.tar.gz fml8-f682fe460ea9cfdf8a17e6f785ce631d8a5c69b1.tar.bz2 fml8-f682fe460ea9cfdf8a17e6f785ce631d8a5c69b1.zip | |
add several hook examples on header rewriting, which questions of
examples are picked up from fml bible.
Diffstat (limited to 'fml')
| -rw-r--r-- | fml/doc/en/tutorial/customize/recipes.header.sgml | 385 | ||||
| -rw-r--r-- | fml/doc/ja/tutorial/customize/recipes.header.sgml | 387 |
2 files changed, 769 insertions, 3 deletions
diff --git a/fml/doc/en/tutorial/customize/recipes.header.sgml b/fml/doc/en/tutorial/customize/recipes.header.sgml index 35f83d20..ee24f7c2 100644 --- a/fml/doc/en/tutorial/customize/recipes.header.sgml +++ b/fml/doc/en/tutorial/customize/recipes.header.sgml @@ -1,5 +1,5 @@ <!-- - $FML: recipes.header.sgml,v 1.1 2006/01/13 00:07:14 fukachan Exp $ + $FML: recipes.header.sgml,v 1.2 2006/01/13 00:15:35 fukachan Exp $ --> <qandaset> @@ -9,6 +9,77 @@ <question> <para> +Add tag such as [elena:00100] at Subject:. +</para> +</question> + +<answer> +<para> +no tag by default. +You can specify subject tag as sprintf form. +<screen> +[/var/spool/ml/elena/config.cf] + +article_subject_tag = [$ml_name:%05d] +</screen> + +</para> +</answer> + +</qandaentry> + + +<qandaentry> + +<question> +<para> +Change digit of the number part of Subject: [elena:00100]. +</para> +</question> + +<answer> +<para> +You can specify subject tag as sprintf form. +For example, %07 if 7 digits. +<screen> +[/var/spool/ml/elena/config.cf] + +article_subject_tag = [$ml_name:%07d] +</screen> + +</para> +</answer> + +</qandaentry> + + +<qandaentry> + +<question> +<para> +no 0 padding in subject tag. +</para> +</question> + +<answer> +<para> + +<screen> +[/var/spool/ml/elena/config.cf] + +article_subject_tag = [$ml_name:%d] +</screen> + +</para> +</answer> + +</qandaentry> + + +<qandaentry> + +<question> +<para> make subject tag uppercase. </para> </question> @@ -195,6 +266,316 @@ $article_header_rewrite_end_hook = q{ </qandaentry> +<qandaentry> -</qandaset> +<question> +<para> +remove X-Face: header field. +</para> +</question> + +<answer> +<para> + +<screen> +unsafe_header_fields += x-face +</screen> + +</para> +</answer> + +</qandaentry> + + +<qandaentry> + +<question> +<para> +copy Sender: field to X-Sender: field. +</para> +</question> + +<answer> +<para> + +<screen> +$article_header_rewrite_end_hook = q{ + my $header = $curproc->article_message_header(); + $header->add('X-Sender', $header->get('Sender')); +}; +</screen> + +</para> +</answer> + +</qandaentry> + + +<qandaentry> + +<question> +<para> +move Received: to X-Received: field. +</para> +</question> + +<answer> +<para> +Copy Received: to X-Received: field and delete Received: after that. +<screen> +$article_header_rewrite_end_hook = q{ + my $header = $curproc->article_message_header(); + $header->add('X-Received', $header->get('Received')); + $header->delete('Received'); +}; +</screen> + +</para> +</answer> + +</qandaentry> + + +<qandaentry> + +<question> +<para> +If the input mail has no Reply-To:, pass it without appending Reply-to: field. +</para> +</question> + +<answer> +<para> +In config.cf, add the following configuration. +<screen> +article_header_rewrite_rules -= rewrite_reply_to +</screen> +</para> + +<para> +By default, &fml8; add "Reply-To: $article_post_address" to +the message without Reply-To: field. +This effect is done by rewrite_reply_to directive in +$article_header_rewrite_rules variable. +So, rewriting of Reply-To: is disabled if you remove the directive. +</para> + +</answer> + +</qandaentry> + +<qandaentry> + +<question> +<para> +Pass To:, Cc: and Reply-To: through. +</para> +</question> + +<answer> +<para> +same as the previous recipe since To: and Cc: is pass through by default. +<screen> +article_header_rewrite_rules -= rewrite_reply_to +</screen> +</para> +</answer> + +</qandaentry> + + +<qandaentry> + +<question> +<para> +Pass Message-ID through. +</para> +</question> + +<answer> +<para> +nothing todo. &fml8; passes Message-ID: field through by default. +</para> +</answer> + +</qandaentry> + + +<qandaentry> + +<question> +<para> +rewrite Message-ID: to ML specific one. +</para> +</question> + +<answer> +<para> + +<screen> +[/var/spool/ml/elena/config.cf] + +$article_header_rewrite_end_hook = q{ + my $header = $curproc->article_message_header(); + + # generate specific Message-Id + my $ml_name = $config->{ ml_name }; + my $ml_domain = $config->{ ml_domain }; + my $new_id = sprintf("%s-%d\@%s", $ml_name, $$, $ml_domain); + + # backup the original Message-Id at X-Message-Id field. + $header->add('X-Message-Id', $header->get('Message-Id')); + + # replace Message-Id field. + $header->replace('Message-Id', $new_id); +}; +</screen> + +</para> +</answer> + +</qandaentry> + + +<qandaentry> + +<question> +<para> +Specify X-ML-Info: field. +</para> +</question> + +<answer> +<para> +Enforce mail header field. +<screen> +$article_header_rewrite_end_hook = q{ + my $header = $curproc->article_message_header(); + $header->replace('X-ML-Info', "oresama id"); +}; +</screen> + +</para> +</answer> + +</qandaentry> + + +<qandaentry> + +<question> +<para> +Specify Reply-To: in system message mail. +</para> +</question> + +<answer> +<para> +unimplemented. +In fact, +<screen> +outgoing_mail_header_reply_to = ADDRESS +</screen> +changes Reply-To: in system message mail but +it is derived from wrong &fml8; implementation. +</para> +</answer> + +</qandaentry> + + +<qandaentry> + +<question> +<para> +Pass only specified header fields. +</para> +</question> + +<answer> +<para> +In the current &fml8; implementation, +you should use the following hook. +<screen> + + $article_header_rewrite_end_hook = q{ + my $header = $curproc->article_message_header(); + my (@tags) = $header->tags(); + + # define valid header fields to allow. + my (@valid_tags) = qw(to from reply-to subject date message-id); + + for my $tag (@tags) { + my $valid = 0; + SCAN: + for my $v (@valid_tags) { + if ($tag =~ /^$v$/i) { + $valid = 1; + last SCAN; + } + } + unless ($valid) { + $header->delete($tag); + } + } + }; + +</screen> + +</para> +</answer> + +</qandaentry> + + +<qandaentry> + +<question> +<para> +Enforce use of In-Reply-To: or References: header field. +</para> +</question> + +<answer> +<para> +There is a reply message to have no In-Reply-To: nor References: header field. +Firstly, It provides no thread relation. +Secondly, it may be a spam message since it is unusual today. +</para> + +<para> +If Subject: field indicates reply message but no +In-Reply-To: nor References: header field, +you can reject this message by using this hook. +<screen> + $article_post_verify_request_end_hook = q{ + my $header = $curproc->incoming_message_header(); + my $subject = $header->get('subject') || ''; + my $in_reply_to = $header->get("In-Reply-To") || ''; + my $references = $header->get("References") || ''; + + my $_subject = new Mail::Message::Subject $subject; + if ($_subject->has_reply_tag()) { + unless ($in_reply_to || $references) { + $curproc->log("reject invalid reply message"); + $curproc->stop_this_process(); + $curproc->policy_reject_this_message(); + } + } + }; +</screen> +In this case error message is sent to the sender. +If you have only to ignore this message not reply, +replace +policy_reject_this_message() +to +policy_ignore_this_message() +method. +</para> +</answer> + +</qandaentry> + + +</qandaset> diff --git a/fml/doc/ja/tutorial/customize/recipes.header.sgml b/fml/doc/ja/tutorial/customize/recipes.header.sgml index c4ddac68..e5820a38 100644 --- a/fml/doc/ja/tutorial/customize/recipes.header.sgml +++ b/fml/doc/ja/tutorial/customize/recipes.header.sgml @@ -1,9 +1,81 @@ <!-- - $FML: recipes.header.sgml,v 1.2 2006/01/13 00:07:14 fukachan Exp $ + $FML: recipes.header.sgml,v 1.3 2006/01/13 00:15:35 fukachan Exp $ --> <qandaset> + +<qandaentry> + +<question> +<para> +Subject: に [elena:00100] のようなタグをつける +</para> +</question> + +<answer> +<para> +デフォルトではタグはつきません。 +&fml8; ではタグを sprintf 形式で指定することになっています。 +<screen> +[/var/spool/ml/elena/config.cf] + +article_subject_tag = [$ml_name:%05d] +</screen> + +</para> +</answer> + +</qandaentry> + + +<qandaentry> + +<question> +<para> +Subject: [elena:00100] の数字部分(00100)の桁数を変える +</para> +</question> + +<answer> +<para> +&fml8; ではタグを sprintf 形式で指定することになっています。 +たとえば7桁なら %07 などとすればよいだけです。 +<screen> +[/var/spool/ml/elena/config.cf] + +article_subject_tag = [$ml_name:%07d] +</screen> + +</para> +</answer> + +</qandaentry> + + +<qandaentry> + +<question> +<para> +Subject: のタグの数字(00100)の0パディングをなくしたい。 +</para> +</question> + +<answer> +<para> + +<screen> +[/var/spool/ml/elena/config.cf] + +article_subject_tag = [$ml_name:%d] +</screen> + +</para> +</answer> + +</qandaentry> + + <qandaentry> <question> @@ -197,4 +269,317 @@ $article_header_rewrite_end_hook = q{ </qandaentry> +<qandaentry> + +<question> +<para> +不要なヘッダフィールド X-Face: を消す +</para> +</question> + +<answer> +<para> +<screen> +unsafe_header_fields += x-face +</screen> +</para> +</answer> + +</qandaentry> + + +<qandaentry> + +<question> +<para> +Sender: を X-Sender: にコピーする。 +</para> +</question> + +<answer> +<para> + +<screen> +$article_header_rewrite_end_hook = q{ + my $header = $curproc->article_message_header(); + $header->add('X-Sender', $header->get('Sender')); +}; +</screen> + +</para> +</answer> + +</qandaentry> + + +<qandaentry> + +<question> +<para> +Received: を X-Received: へ移動させる。 +</para> +</question> + +<answer> +<para> +X-Received: へコピーした後で Received: を消します。 +<screen> +$article_header_rewrite_end_hook = q{ + my $header = $curproc->article_message_header(); + $header->add('X-Received', $header->get('Received')); + $header->delete('Received'); +}; +</screen> + +</para> +</answer> + +</qandaentry> + + +<qandaentry> + +<question> +<para> +元のメールに Reply-To: がなければ、そのままにしたい。 +</para> +</question> + +<answer> +<para> +config.cf で +<screen> +article_header_rewrite_rules -= rewrite_reply_to +</screen> +としてください。 +</para> + +<para> +デフォルトでは Reply-To: のないメールのヘッダに対し「Reply-To: 投稿用 +アドレス」が追加されます。これは article_header_rewrite_rules にある +rewrite_reply_to 命令によります。よって、これをルールから削除してしま +えば Reply-To: に対する書き換えルールが無効となるというわけです。 +</para> +</answer> + +</qandaentry> + + +<qandaentry> + +<question> +<para> +To: Cc: Reply-To: を全部そのまま素通しにする。 +</para> +</question> + +<answer> +<para> +前レシピと同じです。 +</para> + +<para> +To: と Cc: は元々素通しです。そのため config.cf で +<screen> +article_header_rewrite_rules -= rewrite_reply_to +</screen> +とするだけで十分です。 +</para> + +</answer> + +</qandaentry> + + +<qandaentry> + +<question> +<para> +記事の Message-ID: は元の値のまま通したい。 +</para> +</question> + +<answer> +<para> +素通しがデフォルトの挙動ですので、なにもする必要はありません。 +</para> +</answer> + +</qandaentry> + + +<qandaentry> + +<question> +<para> +記事に ML 独自の Message-ID: をつけたい +</para> +</question> + +<answer> +<para> + +<screen> +[/var/spool/ml/elena/config.cf] + +$article_header_rewrite_end_hook = q{ + my $header = $curproc->article_message_header(); + + # Message-Id を生成 (この例は適当です) + my $ml_name = $config->{ ml_name }; + my $ml_domain = $config->{ ml_domain }; + my $new_id = sprintf("%s-%d\@%s", $ml_name, $$, $ml_domain); + + # X-Message-Id にオリジナルの Message-Id をバックアップしておく + $header->add('X-Message-Id', $header->get('Message-Id')); + + # Message-Id を入れ換える + $header->replace('Message-Id', $new_id); +}; +</screen> + +</para> +</answer> + +</qandaentry> + + +<qandaentry> + +<question> +<para> +X-ML-Info: の内容を指定する。 +</para> +</question> + +<answer> +<para> +ようするにメールヘッダの値を強制指定します。 +<screen> +$article_header_rewrite_end_hook = q{ + my $header = $curproc->article_message_header(); + $header->replace('X-ML-Info', "oresama id"); +}; +</screen> + +</para> +</answer> + +</qandaentry> + + +<qandaentry> + +<question> +<para> +レポートメールの Reply-To: を指定する。 +</para> +</question> + +<answer> +<para> +未実装です。 +現在の fml8 でも、実際には +<screen> +outgoing_mail_header_reply_to = アドレス +</screen> +でレポートメールの Reply-To: を指定できるのですが、 +これは今の実装が間違っていますね _o_ +</para> +</answer> + +</qandaentry> + + +<qandaentry> + +<question> +<para> +特定のヘッダだけを通したい +</para> +</question> + +<answer> +<para> +現状の &fml8; では、次のような HOOK で実現するしかありません。 +<screen> + + $article_header_rewrite_end_hook = q{ + my $header = $curproc->article_message_header(); + my (@tags) = $header->tags(); + + # 通したいヘッダフィールドを定義する + my (@valid_tags) = qw(to from reply-to subject date message-id); + + for my $tag (@tags) { + my $valid = 0; + SCAN: + for my $v (@valid_tags) { + if ($tag =~ /^$v$/i) { + $valid = 1; + last SCAN; + } + } + unless ($valid) { + $header->delete($tag); + } + } + }; + +</screen> + +</para> +</answer> + +</qandaentry> + + +<qandaentry> + +<question> +<para> +In-Reply-To: か References: を強制したい。 +</para> +</question> + +<answer> +<para> +記事への返事にも関わらず In-Reply-To: も References: もないメールがあります。 +一つには、スレッド関係が分からないので見づらいという問題があります。 +二つには、通常そういったメールはないので普通のメールではなく SPAM などの +類ではないかという可能性です。 +</para> + +<para> +Subject に返事の印( Re: など)がなく、In-Reply-To: または References: +ヘッダがないなら拒否する HOOK です。 +<screen> + $article_post_verify_request_end_hook = q{ + my $header = $curproc->incoming_message_header(); + my $subject = $header->get('subject') || ''; + my $in_reply_to = $header->get("In-Reply-To") || ''; + my $references = $header->get("References") || ''; + + my $_subject = new Mail::Message::Subject $subject; + if ($_subject->has_reply_tag()) { + unless ($in_reply_to || $references) { + $curproc->log("reject invalid reply message"); + $curproc->stop_this_process(); + $curproc->policy_reject_this_message(); + } + } + }; +</screen> +拒否した旨のメールを送信者へ送っています。 +もしエラーメッセージを送信者に返さず単に無視するだけでいいなら +policy_reject_this_message +を +policy_ignore_this_message +にしてください。 +</para> +</answer> + +</qandaentry> + + </qandaset> |
