ISPConfig · 2 min read · Nov 15, 2025

ISPConfig 2.x: ISPConfigインストールに「スパムに移動」オプションを追加する方法

ISPConfig 2.x: ISPConfigインストールに「スパムに移動」オプションを追加する方法

Version 1.0b
Author: Jens Groh

概要:

この文書では、ISPConfig 2.xインストールに3番目のスパムフィルタ戦略を追加するために必要な手順を説明します。これにより、あなたとあなたのユーザーは、スパムを削除するか、スパムを許可するか、対応するIMAPジャンクメールフォルダに移動するかを選択できるようになります。

このハウツーは、スパムを削除する戦略を移動に交換したと説明した「grant」のフォーラムスレッド(https://www.howtoforge.com/forums/showthread.php?t=15704)に触発されました。以下の手順に従うことで、削除方法を置き換えるのではなく、3番目の方法を得ることができます。

前提条件:

このハウツーでは、以下のような構成を使用していると仮定します:

  • ISPConfig (v2.2.23以降)
  • 設定されて稼働中の少なくとも1つのドメインとメールボックス
  • IMAPはMaildir形式を使用している(mboxでは動作しません!)

ステップ1 - フォームの変更

最初のステップは、AdminアカウントでISPConfigパネルにログインすることです。次に、Administrationタブに入り、Edit FormForm Designerを開きます。isp - ISP Userを検索してeditをクリックします。
今、特定のフォームの完全なフォーム説明が表示されるはずです。spam_strategyを探して再度editをクリックします。
今、将来の移動オプションのための行を挿入して、次のようにValue listを変更します:

accept,accept;
move,move;
discard,discard;

そのフォームを保存します。あなたのドメインのメールユーザーオプションには、スパム戦略のドロップダウンボックスに新しいオプションが表示されるはずです - まだ機能はありませんが。次に、コンソール部分に移ります: 新しいオプションに命を吹き込むためにいくつかのISPConfigファイルを編集しましょう。

ステップ2 - ISPConfigソースファイルの編集

今、いくつかのファイルを編集する必要があります。以下にそれらを書き出し、後で説明します:

vi /root/ispconfig/scripts/lib/classes/ispconfig_procmail.lib.php

(約109行目):

         if(!is_dir($web_path."/user/".$user_username."/Maildir"))
$mod->log->caselog("maildirmake
".$web_path."/user/".$user_username."/Maildir &> /dev/null", "maildirmake
".$web_path."/user/".$user_username."/Maildir &> /dev/null", __LINE__);
        // ADD: IMAPサブフォルダを作成
        if(!is_dir($web_path."/user/".$user_username."/Maildir/.Drafts"))
$mod->log->caselog("maildirmake
".$web_path."/user/".$user_username."/Maildir/.Drafts &> /dev/null",
"maildirmake ".$web_path."/user/".$user_username."/Maildir/.Drafts &>
/dev/null", __LINE__);
        if(!is_dir($web_path."/user/".$user_username."/Maildir/.Junk"))
$mod->log->caselog("maildirmake
".$web_path."/user/".$user_username."/Maildir/.Junk &> /dev/null",
"maildirmake ".$web_path."/user/".$user_username."/Maildir/.Junk &>
/dev/null", __LINE__);
        if(!is_dir($web_path."/user/".$user_username."/Maildir/.Sent"))
$mod->log->caselog("maildirmake
".$web_path."/user/".$user_username."/Maildir/.Sent &> /dev/null",
"maildirmake ".$web_path."/user/".$user_username."/Maildir/.Sent &>
/dev/null", __LINE__);
        if(!is_dir($web_path."/user/".$user_username."/Maildir/.Trash"))
$mod->log->caselog("maildirmake
".$web_path."/user/".$user_username."/Maildir/.Trash &> /dev/null",
"maildirmake ".$web_path."/user/".$user_username."/Maildir/.Trash &>
/dev/null", __LINE__);
 
     if(!is_dir($web_path."/user/".$user_username."/Maildir"))
$mod->log->phpcaselog(mkdir($web_path."/user/".$user_username."/Maildir",
0700), "create ".$web_path."/user/".$user_username."/Maildir", $this->FILE,
__LINE__);
 
        // ADD: IMAPサブフォルダを作成
        if(!is_dir($web_path."/user/".$user_username."/Maildir/.Drafts"))
$mod->log->phpcaselog(mkdir($web_path."/user/".$user_username."/Maildir/.Drafts",
0700), "create ".$web_path."/user/".$user_username."/Maildir/.Drafts",
$this->FILE, __LINE__);
        if(!is_dir($web_path."/user/".$user_username."/Maildir/.Junk"))
$mod->log->phpcaselog(mkdir($web_path."/user/".$user_username."/Maildir/.Junk",
0700), "create ".$web_path."/user/".$user_username."/Maildir/.Junk",
$this->FILE, __LINE__);
  if(!is_dir($web_path."/user/".$user_username."/Maildir/.Sent"))
$mod->log->phpcaselog(mkdir($web_path."/user/".$user_username."/Maildir/.Sent",
0700), "create ".$web_path."/user/".$user_username."/Maildir/.Sent",
$this->FILE, __LINE__);
  if(!is_dir($web_path."/user/".$user_username."/Maildir/.Trash"))
$mod->log->phpcaselog(mkdir($web_path."/user/".$user_username."/Maildir/.Trash",
0700), "create ".$web_path."/user/".$user_username."/Maildir/.Trash",
$this->FILE, __LINE__);
 
     exec("chown -R ".$user_username.":web".$web_doc_id."
".$web_path."/user/".$user_username."/Maildir");
     exec("chmod 700 ".$web_path."/user/".$user_username."/Maildir");
 
  // ADD: IMAPサブフォルダを作成
  exec("chown -R ".$user_username.":web".$web_doc_id."
".$web_path."/user/".$user_username."/Maildir/.Drafts");
  exec("chmod 700 ".$web_path."/user/".$user_username."/Maildir/.Drafts");
  exec("chown -R ".$user_username.":web".$web_doc_id."
".$web_path."/user/".$user_username."/Maildir/.Junk");
  exec("chmod 700 ".$web_path."/user/".$user_username."/Maildir/.Junk");
  exec("chown -R ".$user_username.":web".$web_doc_id."
".$web_path."/user/".$user_username."/Maildir/.Sent");
  exec("chmod 700 ".$web_path."/user/".$user_username."/Maildir/.Sent");
  exec("chown -R ".$user_username.":web".$web_doc_id."
".$web_path."/user/".$user_username."/Maildir/.Trash");
  exec("chmod 700 ".$web_path."/user/".$user_username."/Maildir/.Trash");
 
     if($user["user_admin"]){
       exec("rm -f $web_path/Maildir &> /dev/null");
      
$mod->log->phpcaselog(@symlink($web_path."/user/".$user_username."/Maildir",
$web_path."/Maildir"), "symlink ".$web_path."/Maildir", $this->FILE,
__LINE__);

(約300行目)

   $mod->tpl->define( array(table    => "spamassassin.rc.master"));
 
   if(!isset($user["spam_strategy"])) $user["spam_strategy"] = "accept";

   if($user["spam_strategy"] == "accept"){
     $spam_comment = "#";
     $spam_command = ".Junk/";
   } else {
     $spam_comment = "";
     if($user["spam_strategy"] == "discard"){
       $spam_command = "/dev/null";
     } else {
       $spam_command = ".Junk/";
     }
   }

(約330行目)


if(is_file('/home/admispconfig/ispconfig/tools/spamassassin/usr/local/bin/spamassassin')){
@@ -302,6 +333,7 @@
   // 変数に値を割り当て
   $mod->tpl->assign( array(PREFS_FILE =>
$web_path."/user/".$user_username."/.user_prefs",
                            SPAM_COMMENT => $spam_comment,
                            SPAM_COMMAND => $spam_command,
                            SPAMASSASSIN_PATH => $spamassassin_path,
                                                    USERNAME =>
$user_username));

これにより、コア機能が追加されます。この変更により、メールユーザーが作成されるたびに標準のMaildirメールボックス(Trash、Sent、Junk、Drafts)が追加され、スパムを対応するジャンクフォルダに移動できるようになります。

次のファイル全体で移動文字列を見つけて追加します:

vi /home/admispconfig/ispconfig/lib/classes/ispconfig_isp_user.lib.php

(約102行目)

                         $doc->deck[1]->elements[11]->visible = 0;
                  }
                  $doc->deck[2]->elements[2]->values["accept"] =
$go_api->lng("txt_accept");
                  $doc->deck[2]->elements[2]->values["move"] =
$go_api->lng("txt_move");
                  $doc->deck[2]->elements[2]->values["discard"] =
$go_api->lng("txt_discard");
         }
vi /home/admispconfig/ispconfig/web/mailuser/mail/table/user.table.php

(約135行目)

                                                                   'regex' 
                      => "",
                                                                   'errmsg'
               => "",
                                                                   'value' 
               => array(        "accept" => $app->lng("txt_accept"),
                                                                            
                                             "move"    =>
$app->lng("txt_move"),
                                                                            
                                             "discard" =>
$app->lng("txt_discard"));
 
 $table['spam_hits'] = array('datatype'                 => "VARCHAR",
vi /home/admispconfig/ispconfig/web/mailuser/lib/lang/.lng

(例: en.lng、約33行目)

 $wb["txt_accept"] = "accept";
 $wb["txt_move"] = "move";
 $wb["txt_discard"] = "discard";
vi /home/admispconfig/ispconfig/web/isp_manager/lib/lang/.lng

(例: en.lng、約268行目および452行目)

 $wb["Spamfilter"] = 'Spamfilter';
 $wb["Antivirus"] = 'Antivirus';
 $wb["accept"] = 'accept';
 $wb["move"] = 'move';
 $wb["discard"] = 'discard';
 $wb["Spam Strategie"] = 'Spam Strategy';
 $wb["Spam Hits"] = 'Spam Hits';
(...) 
 $wb["Keine Vorlage verwenden"] = "Individual Settings";
 $wb["Keine Vorlage vorhanden"] = "No Hostingplan Available";
 $wb["txt_accept"] = "accept";
 $wb["txt_move"] = "move";
 $wb["txt_discard"] = "discard";
 $wb["Eigenschaften"] = "Properties";
 $wb["ISP Datenベース"] = "ISP Database";
vi /home/admispconfig/ispconfig/web/isp_kunde/lib/lang/**.lng

(例: en.lng、約268行目および449行目)

 $wb["Spamfilter"] = 'Spamfilter';
 $wb["Antivirus"] = 'Antivirus';
 $wb["accept"] = 'accept';
 $wb["move"] = 'move';
 $wb["discard"] = 'discard';
 $wb["Spam Strategie"] = 'Spam Strategy';
 $wb["Spam Hits"] = 'Spam Hits';
(...) 
 $wb["Keine Vorlage verwenden"] = "Individual Settings";
 $wb["Keine Vorlage vorhanden"] = "No Hostingplan Available";
 $wb["txt_accept"] = "accept";
 $wb["txt_move"] = "move";
 $wb["txt_discard"] = "discard";
 $wb["Eigenschaften"] = "Properties";
 $wb["ISP Datenベース"] = "ISP Database";

最後の3つの変更は、言語ファイルごとに行う必要があります。さもなければ、インターフェースは対応する用語の代わりに単にmoveを表示します。これらのディレクトリ内のen.lngファイルからの3つの例のスニペットを示しました。他の言語も同様に編集してください(他のものの間にmoveエントリを挿入します)。

ステップ3 - カスタマイズされたテンプレートの作成

次に、/root/ispconfig/isp/confディレクトリに移動し、spamassassin.rc.masterのカスタムコピーを作成します:

cd /root/ispconfig/isp/conf  
cp -pr spamassassin.rc.master ./customized_templates/ cd customized_templates

今、必要な変更を反映するようにカスタムテンプレートを編集します:

# スパムとしてタグ付けされたすべてのメール(設定されたしきい値を超えるスコアを持つ)は
# "/dev/null"に移動されます。
{SPAM_COMMENT}:0:
{SPAM_COMMENT}* ^X-Spam-Status: Yes
{SPAM_COMMENT}{SPAM_COMMAND}

ステップ4(オプション) - ゴミ箱とスパムフォルダのクリーンアップの実装

これは、MuisjeNLによって次のハウツーで既に取り上げられています: ISPConfigによるゴミ箱および/またはジャンクフォルダの自動クリーンアップ(Roundcube + Tmpreaper / Tmpwatchを使用)

ステップ5(オプション) - ユーザーフレンドリーさの実装とステータスメールの作成

これは現在、かなりの開発が行われており、現時点ではかなりハッキングされたperlコードを使用しています。それを整理するか、きれいなスクリプトに移行しようとしています。

結論

これで、メールユーザーを追加する(または既存のものを変更する)ことで新しいmoveメソッドを使用できるようになります。私は、1日に約100〜200通のスパムメールを受信するユーザーでテストし、彼の戦略をmoveに変更しました。RoundcubeのようなウェブメールクライアントやIMAPを介してメールボックスに接続することで、最初のメールが受信トレイではなくジャンクフォルダに落ちるのをほぼ即座に確認しました。

実際の運用サーバーで実行する前に、これを確認してください。
このチュートリアルには、いかなる保証もありません。賢明に、テストしてください!

これは私にとってHowtoForgeでの最初のハウツーであり(私はネイティブスピーカーではありません)、あなたがそれをあなたのニーズに適応させるのに問題がないことを願っています。素晴らしいソフトウェアISPConfigを楽しんでください!

Jens Groh for SANlutions Ltd.

Share: X/Twitter LinkedIn

新しい投稿を受信箱で受け取る

スパムはありません。いつでも購読を解除できます。