<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- Start of mfilter.htm --><!-- delayed after doctype-->
<html>
<head>
<link rel="stylesheet" type="text/css" href="template/css2/netwin.css">
	<script type="text/javascript" src="template/js2/netwin.js"></script>
<!--
	<script type="text/javascript" src="template/js2/dbg.js"></script>
-->

<!--
	<link rel="stylesheet" type="text/css" href="template/css2/netwin.css">

	<link rel="stylesheet" type="text/css" href="template/css2/test.css">
	<link rel="stylesheet" type="text/css" href="template/css2/sw.css">
	<link id ="cnr_css" rel="stylesheet" type="text/css" href="template/css2/cnr4.css">
-->

<!--[if lt IE 7]>
	<link rel="stylesheet" href="template/css2/ie6.css" type="text/css" />
<![endif]-->


<!-- Back to mfilter.htm -->

<!-- #BeginEditable "Headerstuff"-->
<title>MFilter rule syntax</title>
<META NAME="keywords" CONTENT="">
<META NAME="description" CONTENT="">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">


<!-- #EndEditable -->
</head>
<body class="s_body">


<div id="width_limit_div" class="width_limit" style="padding-bottom:0;">

<!-- HEADER CONTENT -->
<div class="header">
  <div class="search_box"><table valign="center" cellSpacing="0" cellPadding="0" border="0">
	<form id="form1" name="form1" method="GET" action="http://www.google.com/custom">

	  <input type=hidden name=domains id=search_domains value="netwinsite.com">
	  <input type=hidden name=sitesearch id=search_sitesearch value="netwinsite.com">
	  <input type=hidden name=cof VALUE="LW:135;L:http://www.netwinsite.com/img2/logo_med_onwhite.png;LH:44;AH:center;S:http://www.netwinsite.com;AWFID:773914251fd85055;">

	  <tr valign="center">
		<td valign="center" style="padding-right:5px;"><span id="search_description" style="font-family:Verdana,Arial,Helvetica; font-size:9pt; ">Search website:</span>
		</td>
		<td valign="center">
			<input size="15" maxLength="80" name="q" style="font-family: Tahoma, Arial; font-size: 8pt">
		</td>
		<td valign="center">
			<input TYPE="image" src="template/img2/search.gif" alt="Search Netwinsite.com!" Name="I1" style="width:17px;height:17px;margin-left:5px;border:0;">
		</td>
	  </tr>
	</form>
  </table></div>

  <div class="page_logo"><table valign="center" border="0" cellpadding="0" cellspacing="10" >
	  <tr>
		<td style="padding-left:20px;">
		  <a href=""><img border="0" src="template/img2/logo_med_onwhite.png" height="44px" vspace="5" id="main_logo"> </a>
		</td>
		<td>
		  <div style="padding-top:14px;">
			<span class="s_header_text">Advanced Server Software<span>
		  </div>
		</td>
	  </tr>
  </table></div>
</div>

<!-- MENU CONTENT -->
<div class="bar_padding" onmousemove="stopEvent(event);return false;">
	<div class="bar" style="text-align:center">
		<table id="page_menu" class="t menu" onmousemove="menu_handler(event);" style="margin:auto"><tr>
	<td valign=top><table class="top_item" mid="menu_home"><tr><td class="btn_l"><td class="btn_c"><a href="http://netwinsite.com/index.htm" class="pad">Home</a><td class="btn_r"></table>
	<td valign=top><table class="top_item" mid="menu_products"><tr><td class="btn_l"><td class="btn_c"><a href="http://netwinsite.com/products.htm" class="pad">Products</a><td class="btn_r"></table>
	<td valign=top><table class="top_item" mid="menu_download"><tr><td class="btn_l"><td class="btn_c"><a href="http://netwinsite.com/download.htm" class="pad">Download</a><td class="btn_r"></table>
	<td valign=top><table class="top_item" mid="menu_buy"><tr><td class="btn_l"><td class="btn_c"><a href="http://netwinsite.com/prices.htm" class="pad">Buy&nbsp;Now</a><td class="btn_r"></table>
	<td valign=top><table class="top_item" mid="menu_support"><tr><td class="btn_l"><td class="btn_c"><a href="http://netwinsite.com/support.htm" onmouseup="x()" class="pad">Support</a><td class="btn_r"></table>
	<td valign=top><table class="top_item" mid="menu_company"><tr><td class="btn_l"><td class="btn_c"><a href="http://netwinsite.com/company.htm" onmouseup="x()" class="pad">Company</a><td class="btn_r"></table>
		</table>
	</div>

	<div id="menu_home" class="xmenu hidden" onmouseup="menu_hide_ex(event,'menu_home')" onmouseout="menu_action_mouseout(event,'menu_home')" onmouseover="menu_action_mouseover(event,'menu_home')" style="width:220px; display:none;">
	</div>

	<div id="menu_products" class="xmenu hidden" onmouseup="menu_hide_ex(event,'menu_products')" onmouseout="menu_action_mouseout(event,'menu_products')" onmouseover="menu_action_mouseover(event,'menu_products')" style="width:220px;">
		<a href="http://netwinsite.com/surgemail/" class="menu_row pad2"><div class="menu_icon_surgemail"></div>
			SurgeMail<span class="menu_extra"></span><br><span class="menu_info">Fully featured email server </span></a>
		<a href="http://netwinsite.com/surgeftp/" onmouseup="x()" class="menu_row pad2 divider"><div class="menu_icon_surgeftp"></div>
			SurgeFTP<span class="menu_extra"></span><br><span class="menu_info">High performance FTP server </span></a>
		<a href="http://netwinsite.com/dbabble/index.html" onmouseup="x()" class="menu_row pad2"><div class="menu_icon_dbabble"></div>
			DBabble <span class="menu_extra"></span><br><span class="menu_info">Instant messenging server </span></a>
		<a href="http://netwinsite.com/surgeweb/" onmouseup="x()" class="menu_row pad2 divider"><div class="menu_icon_surgeweb"></div>
			SurgeWeb<br><span class="menu_info">Modern Ajax web email client</span></a>
		<a href="http://netwinsite.com/products.htm" onmouseup="x()" class="menu_row divider">
			All products...</a>
	</div>

	<div id="menu_download" class="xmenu hidden" onmouseup="menu_hide_ex(event,'menu_download')" onmouseout="menu_action_mouseout(event,'menu_download')" onmouseover="menu_action_mouseover(event,'menu_download')" style="width:220px">
		<a href="/cgi-bin/keycgi.exe?cmd=download&product=surgemail&" onmouseup="x()" class="menu_row"><div class="menu_icon_surgemail"></div>
			Surgemail<span class="menu_extra"></span></a>
		<a href="/cgi-bin/keycgi.exe?cmd=download&product=surgeftp&" onmouseup="x()" class="menu_row"><div class="menu_icon_surgeftp"></div>
			SurgeFTP<span class="menu_extra"></span></a>
		<a href="http://netwinsite.com/dbabble/download.htm" onmouseup="x()" class="menu_row"><div class="menu_icon_dbabble"></div>
			DBabble <span class="menu_extra"></span></a>
		<a href="/cgi-bin/keycgi.exe?cmd=download&product=surgemail&" onmouseup="x()" class="menu_row divider"><div class="menu_icon_surgeweb"></div>
			SurgeWeb</a>
		<a href="http://netwinsite.com/surgemail/help/install.htm" onmouseup="x()" class="menu_row">
			Installing Surgemail</a>
		<a href="http://netwinsite.com/download.htm" onmouseup="x()" class="menu_row">
			Download any product...</a>
	</div>

	<div id="menu_buy" class="xmenu hidden" onmouseup="menu_hide_ex(event,'menu_buy')" onmouseout="menu_action_mouseout(event,'menu_buy')" onmouseover="menu_action_mouseover(event,'menu_buy')" style="width:220px">
		<a href="http://netwinsite.com/prices.htm" onmouseup="x()" class="menu_row divider">
			Pricing</a>
		<a href="http://netwinsite.com/https://netwinsite.com/cgi-bin/keycgi.exe?cmd=buy_new&product=surgemail" onmouseup="x()" class="menu_row"><div class="menu_icon_surgemail"></div>
			Surgemail<span class="menu_extra"></span></a>
		<a href="http://netwinsite.com/https://netwinsite.com/cgi-bin/keycgi.exe?cmd=buy_new&product=surgeftp" onmouseup="x()" class="menu_row"><div class="menu_icon_surgeftp"></div>
			SurgeFTP<span class="menu_extra"></span></a>
		<a href="http://netwinsite.com/https://netwinsite.com/cgi-bin/keycgi.exe?cmd=buy_new&product=dbabble" onmouseup="x()" class="menu_row"><div class="menu_icon_dbabble"></div>
			DBabble <span class="menu_extra"></span></a>
		<a href="http://netwinsite.com/https://netwinsite.com/cgi-bin/keycgi.exe?cmd=buy_new&product=surgemail" onmouseup="x()" class="menu_row divider"><div class="menu_icon_surgeweb"></div>
			SurgeWeb</a>
		<a href="http://netwinsite.com/activate.htm" onmouseup="x()" class="menu_row">
			Activation guide</a>
		<a href="http://netwinsite.com/prices.htm" onmouseup="x()" class="menu_row">
			Purchase any product...</a>
	</div>

	<div id="menu_support" class="xmenu hidden" onmouseup="menu_hide_ex(event,'menu_support')" onmouseout="menu_action_mouseout(event,'menu_support')" onmouseover="menu_action_mouseover(event,'menu_support')" style="width:220px">
		<a href="http://netwinsite.com/documentation.htm" onmouseup="x()" class="menu_row divider">
			Online documentation<span class="menu_extra"></span></a>
		<a href="http://netwinsite.com/surgemail/post.htm" onmouseup="x()" class="menu_row">
			Contact support<span class="menu_extra"></span></a>
		<a href="http://netwinsite.com/support.htm#email_list" onmouseup="x()" class="menu_row">
			Standard email support<span class="menu_extra"></span></a>
		<a href="http://netwinsite.com/http://news.netwinsite.com:8119/webnews?group=netwin.surgemail&cmd=list" onmouseup="x()"  class="menu_row divider">
			Community forum <span class="menu_extra"></span></a>
		<a href="http://netwinsite.com/support.htm" onmouseup="x()" class="menu_row">
			Support overview...</a>
	</div>

	<div id="menu_company" class="xmenu hidden" onmouseup="menu_hide_ex(event,'menu_company')" onmouseout="menu_action_mouseout(event,'menu_company')" onmouseover="menu_action_mouseover(event,'menu_company')" style="width:220px">
		<a href="http://netwinsite.com/company.htm" onmouseup="x()" class="menu_row">
			About us<span class="menu_extra"></span></a>
		<a href="http://netwinsite.com/surgemail/customers.htm" onmouseup="x()" class="menu_row">
			Customers<span class="menu_extra"></span></a>
		<a href="http://netwinsite.com/support.htm#sales_questions" onmouseup="x()" class="menu_row divider">
			Contact us</a>
	</div>
	<div style="background:url(template/img2/white_small.png);height:8px;font-size:1px;"></div>
</div>
<!-- Back to mfilter.htm -->

<div class="content_outer">


<!-- Back to mfilter.htm -->
<div class="L2C2_column_left">
<!-- Back to mfilter.htm -->
<div style="width:160px;">
  <div id="floating_index" class="floating_index nav-menu _document_index" style="width:160px;">
	<h2 class="menu_top">Help Index</h2>
	<ul class="level-0">

		<li class="group_hidden"><a href="#" onclick="index_toggle(event)">Getting Started</a><ul class="level-1">
			<li id="idx_surgemail.htm"><a href="surgemail.htm" target="_top">SurgeMail in a nutshell</a><ul class="level-2"></ul></li>
			<li id="idx_startingoff.htm"><a href="startingoff.htm" target="_top">Before you install</a><ul></ul></li>
			<li id="idx_install.htm"><a href="install.htm" target="_top">Installation &amp; Upgrading</a><ul></ul></li>
			<li id="idx_migration.htm"><a href="migration.htm" target="_top">Migration to SurgeMail</a><ul></ul></li>
			<li id="idx_updates.htm"><a href="updates.htm" target="_top">Change history</a><ul></ul></li>
			<li id="idx_postinstall.htm"><a href="postinstall.htm" target="_top">Post Installation</a><ul></ul></li>
			<li id="idx_faq.htm"><a href="faq.htm" target="_top">FAQ</a><ul></ul></li>
			<li id="idx_support.htm"><a href="support.htm" target="_top">Customer Support</a><ul></ul></li>
		</ul></li>

		<li class="group_hidden"><a href="#" onclick="index_toggle(event)">Anti Spam / Virus</a><ul class="level-1">
			<li id="idx_protected.htm"><a href="protected.htm#virusscanner">Virus Protection</a></li>
			<li id="idx_spam.htm"><a href="spam.htm">Spam Prevention</a></li>
			<li id="idx_protected.htm"><a href="protected.htm#mfilter">Mail Filtering</a> </li>
			<li id="idx_protected.htm"><a href="protected.htm#friends">Friendly Relations System</a></li>
			<li id="idx_rbl.htm"><a href="rbl.htm">Realtime Blackhole Lists</a></li>
		</ul></li>

		<li class="group_hidden"><a href="#" onclick="index_toggle(event)">Server Management </a><ul class="level-1">
			<li id="idx_status.htm"><a href="status.htm">Server Status</a></li>
			<li id="idx_log.htm"><a href="log.htm">Searching the log files</a></li>
			<li id="idx_report.htm"><a href="report.htm">Report generation</a></li>
			<li id="idx_accounts.htm"><a href="accounts.htm">Managing accounts</a></li>
			<li id="idx_tellmail.htm"><a href="tellmail.htm">Using the tellmail utility.</a></li>
		</ul></li>
		
		<li class="group_hidden"><a href="#" onclick="index_toggle(event)">SurgeMail Settings</a><ul class="level-1">
			<li id="idx_domain.htm"><a href="domain.htm">Domain specific settings</a></li>
			<li id="idx_global.htm"><a href="global.htm">Global settings</a></li>
			<li id="idx_webmail.htm"><a href="webmail.htm">WebMail settings</a></li>
		</ul></li>

		<li class="group_hidden"><a href="#" onclick="index_toggle(event)">Configuration Guides</a><ul class="level-1">
			<li id="idx_authent.htm"><a href="authent.htm">Authentication  Modules</a></li>
			<li id="idx_domains.htm"><a href="domains.htm">Virtual  Domains</a></li>
			<li id="idx_clustering.htm"><a href="clustering.htm">Clustering</a></li>
			<li id="idx_mirror.htm"><a href="mirror.htm">Mirror the server</a></li>
			<li id="idx_scalable.htm"><a href="scalable.htm">Performance &amp; Scalability</a></li>
			<li id="idx_lookandfeel.htm"><a href="lookandfeel.htm">Custom look and feel</a></li>
			<li id="idx_internal_email.htm"><a href="internal_email.htm">Custom internal emails </a></li>
			<li id="idx_language.htm"><a href="language.htm">Language translation</a></li>
			<li id="idx_redirection.htm"><a href="redirection.htm">Mail Redirection</a></li>
			<li id="idx_surgewall.htm"><a href="surgewall.htm">SurgeWall</a></li>
			<li id="idx_sms.htm"><a href="sms.htm">SMS</a></li>
			<li id="idx_lists.htm"><a href="lists.htm">Mailing lists and bulletins</a></li>
			<li id="idx_secure.htm"><a href="secure.htm">Securing the server</a></li>
			<li id="idx_incoming.htm"><a href="incoming.htm">Incoming MX servers</a></li>
			<li id="idx_load_balance.htm"><a href="load_balance.htm">Load balancing</a></li>
			<li id="idx_ndb.htm"><a href="ndb.htm">NDB NetWin folder format</a></li>
			<li id="idx_domainkeys.htm"><a href="domainkeys.htm">DomainKeys Support</a></li>
			<li id="idx_ipv6.htm"><a href="ipv6.htm">IPV6 Support</a></li>
			<li id="idx_examples.htm"><a href="examples.htm">Example configurations</a></li>
		</ul></li>
	</ul>
  </div>
  &nbsp;	<!-- required to render div -->
</div>
<script>window.do_scroll_menu=false</script>
<!-- Back to mfilter.htm -->
</div>

<!-- Back to mfilter.htm -->

<div class="L2C2_column_content">
<!-- Back to mfilter.htm -->
<!-- #BeginEditable "Body" -->


  <script language="JavaScript"> search_details('Search SurgeMail Manual:','http://netwinsite.com/surgemail/help'); </script>
  <script language="JavaScript"> display_crumbs_doc(['Home','Documentation','SurgeMail Help Index','Log Searching'],3); </script>
  <script language="JavaScript"> index_select('idx_mfilter.htm'); </script>

  <h1>Mfilter Rule Syntax</h1>

  <h3>Design Goals:</h3>
  <ul>
    <li><font face="Arial, Helvetica, sans-serif"> Fast processing of incoming
      messages.</font></li>
    <li><font face="Arial, Helvetica, sans-serif"> A simple, clear, syntax so
      that rules can easily be understood and modified</font></li>
    <li><font face="Arial, Helvetica, sans-serif"> Enough power/flexibility</font></li>
    <li><font face="Arial, Helvetica, sans-serif"> Incorporate regular expression
      matching to give real power.</font></li>
    <li><font face="Arial, Helvetica, sans-serif"> Not to create a new elaborate
      language if possible.</font></li>
  </ul>
  <h3>How to configure rules:</h3>
  <ul>
    <li><font face="Arial, Helvetica, sans-serif"> Simply create a file called
      <b>mfilter.rul</b> in the <b>SurgeMail work area</b> (as defined in SurgeMails
      config)</font></li>
    <li><font face="Arial, Helvetica, sans-serif"> Use the test command via the
      SurgeMail admin interface to check that your filter works as expected</font></li>
    <li>Please note that &quot;local.rul&quot; should be used for adding scoring
      for ASPAM not mfilter.rul. </li>
  </ul>
  <h3>Tracing problems </h3>
  <p><font face="Arial, Helvetica, sans-serif">If you have problems getting mfilter
    to run you can use these two settings in surgemail.ini, they will provide
    logging to show exactly what is going on.</font></p>
  <pre>g_mfilter_trace &quot;true&quot;
g_mfilter_noisey &quot;true&quot;</pre>
  <p>then examine 'mail.log' after sending in a test message.</p>

  <h2>Syntax Of mfilter.rul File</h2>
  <h3>There are 6 valid statements
    in a rule file:</h3>
  <blockquote><font face="Arial, Helvetica, sans-serif">Assignment <br>
    Action <br>
    if (Conditional_Expression) [and (Conditional_Expression)...] Action <br>
    else <br>
    end if <br>
    call built_in_function()</font></blockquote>
  <h3>Assignment</h3>
  <blockquote><font face="Arial, Helvetica, sans-serif">$variable_name = "quoted
    string" [+ "quoted string" [+ $variable ...]] <br>
    $variable_name = function()</font></blockquote>
  <h3>Action</h3>
  <blockquote><font face="Arial, Helvetica, sans-serif">accept "reason" | bounce
    "reason" | drop "reason" | forward "user@domain" | then | setflag("flagname")
    | clearflag("flagname")</font></blockquote>
  <h3>Conditional Expression (if, else, end if)</h3>
  <blockquote><font face="Arial, Helvetica, sans-serif">Any pre-defined function,
    e.g. isbinary() <br>
    isin("subject","free pictures") <br>
    Numeric comparisons, e.g. lines()>100 <br>
    Simple NOT operator, e.g. if (!isbinary()) reject "Only binaries allowed here
    mate!" <br>
    Calculations are NOT permitted, e.g. lines()+10 would fail</font></blockquote>
  <h3>Recipients block for processing
    individual recipients</h3>
  <blockquote><font face="Arial, Helvetica, sans-serif">A single mail message
    may have many recipients, and in many cases the actions of your spam filter
    should vary depending on the recipients (you might, for example, want all
    messages to your account to get through even if the same message would be
    blocked if sent to any other user). </font>
    <p><font face="Arial, Helvetica, sans-serif">The recipient block (recipients...end
      recipients) is processed once for each recipient of the message. </font>
    <p><font face="Arial, Helvetica, sans-serif">Inside the 'recipients' block
      there is a dummy variable defined 'recipient' which is the specific recipient
      in question. </font>
    <p><font face="Arial, Helvetica, sans-serif">All the action's (except, bounce,
      drop) refer to the recipient only, not to the entire message, so when one
      of those actions that normally terminates message processing is encountered
      (accept, bounce, drop, etc) instead the action is applied only to that recipient
      and the recipient block is restarted with the next recipient defined. </font>
    <p><font face="Arial, Helvetica, sans-serif">(Example of mfilter rule to do
      processing 'per recipient') </font>
    <pre><font face="Arial, Helvetica, sans-serif">recipients
       if (isin("recipient","manager@this.domain")) accept "Always accept for me        so spammers can talk to me"
       if (isin("recipient","sales@your.domain")) then
       	if (isin("subject","order")) then
       		# Make a Duplicate of sale order
       		call forward_cc(<a href="mailto:sales_copy@your.domain">"sales_copy@your.domain"</a>)
       	end if
       end if
end recipients</font> </pre>
  </blockquote>

  <h2>Miscellaneous</h2>
  <h3>Line Continuation</h3>
  <blockquote><font face="Arial, Helvetica, sans-serif">Lines can be continued
    by ending the line in a '\' character</font></blockquote>
  <h3>Quoting Strings</h3>
  <blockquote><font face="Arial, Helvetica, sans-serif">All strings and header
    names should be within double quotes, sometimes you may get away without doing
    this, but we don't guarantee this will work in future. e.g. use: exists("Supersedes")
    not exists(Supersedes); quotes can be escaped in the usual way, e.g. "This
    \"Word\" has quotes around it"</font></blockquote>
  <h3>Assignments</h3>
  <blockquote><font face="Arial, Helvetica, sans-serif">Assignments are processed
    at compile time, variables DO NOT exist at run time. Do not think of this
    as a programming language, but rather as a list of rules that are processed
    with each incoming message. Real run-time variables only exist in the form
    of the ifflag("xxx") function and the setflag("xxx") action. </font>
    <p><font face="Arial, Helvetica, sans-serif">For example, the following is
      NOT VALID, as the assignment is processed before the rules are run. The
      rejection would always read "big message" </font>
      <pre>$fred = "small message"
if (lines()>100) then
&nbsp;&nbsp; $fred = "big message" (this will not work as expected)
end if
reject $fred</pre>
  </blockquote>
  <h3>Odd stuff</h3>
    <blockquote>
      <p><font face="Arial, Helvetica, sans-serif">The statement '<b>do_bounce_fast</b>'
        should appear at the end of your mfilter.rul file, and it is used by the
        rexp_fast() rules. <b>rexp_fast</b> acts just like rexp() but it is much
        faster because it searches the message once for all of the rules in question,
        each rule must start with two simple non 'regular expression' characters.
        This enables mfilter to generate a hash table of all the regular expressions
        it's going to search for and then it can efficiently apply only the ones
        that appear to match as it runs through the message. Also rexp_fast includes
        the score to apply if the message matches the rule. </font></p>
    </blockquote>
  <h2>Actions &amp; Commands</h2>
  <h3>Actions</h3>
  <blockquote>
    <p><font face="Arial, Helvetica, sans-serif"><a href="#accept">accept</a>"reason"
    (Terminates processing)
    </font><font face="Arial, Helvetica, sans-serif"><br>
      <a href="#bounce">bounce</a> "reason" (Terminates processing) <br>
      <a href="#reject">reject</a> "reason" (same as bounce) <br>
      <a href="#forward">forward</a> "reason" (Terminates processing) (redirect
      is a synonym for this action)<br>
      <a href="#print">print</a> "reason" (Prints debugging line to log file mail.log)
      <br>
      <a href="#setflag">setflag("flagname")</a> "reason" <br>
    <a href="#clearflag">clearflag("flagname")</a> "reason" </font>    </p>
    <p><font face="Arial, Helvetica, sans-serif">Functions that have actions but
      must be proceeded by the 'call' action as they are really functions and
      must be on a line of their own (not on the end of an if statement) </font>
    <p><font face="Arial, Helvetica, sans-serif">call <a href="#forwardcc">forward_cc</a>("new@email.address)
      <br>
      call <a href="#replace">replace</a>("header_name","wildcard_match_pattern","replacement_pattern")
      <br>
      call <a href="#report">report</a>("manger@email.address","subject of message")</font>
  </blockquote>
  <h3>Builtin Functions</h3>
  
<blockquote> 
  <p><font face="Arial, Helvetica, sans-serif"><a href="#add_header"> call add_header</a>(&quot;Header: 
    header information&quot;) <br>
    <a href="#allmod"> allmod</a>() <br>
    <a href="#exists">exists</a>("header")<br>
    <a href="#head_len">head_len</a>("header")<br>
    <a href="#isbase64">isbase64</a>() <br>
    <a href="#isbinary">isbinary</a>() )<br>
    <a href="#isencodedhtml">isencodedhtml</a>() <br>
    <a href="#isencodedtext">(isencodedtext</a>() <br>
    <a href="#isencodedurl">isencodedurl</a>() <br>
    <a href="#isflag">isflag</a>("flag-name") <br>
    <a href="#ishtml">ishtml</a>() <br>
    <a href="#isimage">isimage</a>() <br>
    <a href="#isin">isin</a>("header","string-not-case-sensitive") <br>
    <a href="#lines">lines</a>()&gt;3) <br>
    <a href="#match">match</a>("header","wildcard") <br>
    <a href="#matchall">matchall</a>("header","wildcardlist") <br>
    <a href="#matchone">matchone</a>("header","wildcardlist") <br>
    <a href="#rexp">rexp</a>("header","regular-expression") <br>
    <a href="#size">size</a>() <br>
    <a href="#spamdetect">call spamdetect</a>(n,"reason") <br>
    <a href="#spawn">call spawn</a>("d:/surge/filter.exe $FILE$")</font></p>
  <p>&nbsp;</p>
  <p><font face="Arial, Helvetica, sans-serif">New Functions</font></p>
  <blockquote> 
    <p>time_hour() - returns the 'hours' 0-23, useful for rules that apply at 
      different times of day<br>
      time_min() - returns the minutes<br>
      isimage() - True if message contains an image<br>
      isjpg() - True if message contains a jpeg image<br>
      ispdf() - True if message contains a pdf file<br>
      image_size() - Approx size of image in bytes<br>
      nimage() - Approx number of images found in message<br>
      islocal() - Message is to a local user not an outgoing message<br>
      isloggedin() - Message is from a logged in local user<br>
      is_dayofweek(&quot;monday,tuesday&quot;) - True on those days of the week.<br>
    </p>
  </blockquote>
</blockquote>
  <h3>Notes</h3>
  <blockquote><font face="Arial, Helvetica, sans-serif"> The "header" parameter
    can be any normal header, such as "Subject", "From" or "To". However, the
    are some additional pseudo-headers than can also be used as parameters in
    any function which takes a "header" parameter:<br>
    <br>
    "head": refers to the entire message header.<br>
    "body": refers only to the message body (after any necessary decoding)<br>
    "urls": refers to any urls found in the body<br>
    </font></blockquote>

  <h2>Function Descriptions</h2>
  <h3><a name="add_header"></a>call add_header(&quot;Header: header information&quot;)</h3>
  <p>Used to add a header to a message. eg</p>
  <pre>if (isin(&quot;x-spamdetect&quot;,&quot;****&quot;) then
call add_header(&quot;X-MailScanner-SpamCheck: LEVEL=****&quot;)
end if </pre>
  <h4>NOTE: This will cause bounces
    if used in local.rul or simple.rul, it can only be used in mftiler.rul</h4>
  <p><font face="Arial, Helvetica, sans-serif">Requires Version 3.8 or later.</font></p>
  <h3>allmod("header")</h3>
  <font face="Arial, Helvetica, sans-serif">This returns true if all the newsgroups
  in the specified header are moderated. </font>
  <h3>exists("header")</h3>
  <font face="Arial, Helvetica, sans-serif">This is true if the header exists
  in the message and is non zero in length, eg: if (exists("supersedes")) then
  reject "We don't like supersedes headers" </font>
  <h3>head_len("header")</h3>
  <font face="Arial, Helvetica, sans-serif">Returns the length of the named header,
  e.g. <pre>if (head_len("date")>60) bounce "Naughty message"</pre> </font>
  <h3>isbase64()</h3>
  <font face="Arial, Helvetica, sans-serif">This is true if the message appears
  to contain base64 binary encoded data. </font>
  <h3>isbinary()</h3>
  <font face="Arial, Helvetica, sans-serif">This is true if the message has binary
  data either base64 encoding or uuencoded data. </font>
  <h3>isencodedhtml()</h3>
  <font face="Arial, Helvetica, sans-serif">This is true if the message appears
  to contain MIME or uuencoded HTML instead of plain text data. </font>
  <h3>isencodedtext()</h3>
  <font face="Arial, Helvetica, sans-serif">This is true if the message appears
  to contain MIME or uuencoded text data.&nbsp; This will always be true if isencodedhtml()
  returns true. </font>
  <h3>isencodedurl()</h3>
  <font face="Arial, Helvetica, sans-serif">This is true if the message appears
  to contain an uuencoded URL reference. </font>
  <h3>isflag("flag-name")</h3>
  <font face="Arial, Helvetica, sans-serif">Used to check whether a flag variable
  has been defined as true. This can be done with the setflag("flag-name") action,
  e.g. </font>
  <pre>if (size()>100000) setflag("bigitem")
if (isimage()) setflag("bigitem")
if (isflag("bigitem")) reject "It was a big item or had a picture in it"</pre>
  <h3><a NAME="ishtml"></a>ishtml() </h3>
  <p><font face="Arial, Helvetica, sans-serif">This is true if the message appears
    to contain HTML instead of plain text data. </font>
  <h3>isimage()</h3>
  <font face="Arial, Helvetica, sans-serif">This is true if the message appears
  to contain a picture (either MIME or uuencoded) </font>
  <h3>isin("header","string-not-case-sensitive")</h3>
  <font face="Arial, Helvetica, sans-serif">This is a simple 'content' searching
  function if the named header contains the string (a non case sensitive match
  is used) eg:</font>
  <pre>if (isin("Subject","Free"))
reject "Probably a spammer selling something"</pre>
  <font face="Arial, Helvetica, sans-serif">This would reject a message containing
  a subject of "Get your Free pictures here" it would also reject a message containing
  a subject of "Is there any real freedom in the world?" so it's probably not
  a good rule :-) </font>
  <h3>lines()</h3>
  <font face="Arial, Helvetica, sans-serif">This returns the number of lines in
  the message. </font>
  <h3>match("header","wildcard")</h3>
  <font face="Arial, Helvetica, sans-serif">This function applies a simple wild
  card matching algorithm as is typically used to match file names, eg:
  <pre>match("From","*@netwin.co.nz*")</pre>
  would match against a message from that domain. </font>
  <h3>matchall("header","wildcardlist")</h3>
  <p><font face="Arial, Helvetica, sans-serif">Used for matching a single wild
    card</font><font face="Arial, Helvetica, sans-serif"> against a header which
    contains a list of values, like Newsgroups:, Path: etc..., The match is TRUE
    only if all entries in the list match, eg: </font></p><font face="Arial, Helvetica, sans-serif">
    <pre>if (matchall("Newsgroups","news.filters.*")) accept "It is only in the filters list so we will accept it"</pre>
  <h3>matchone("header","wildcardlist")</h3>
  <font face="Arial, Helvetica, sans-serif">Identical to the above function but
  returns 'TRUE' if any match occurs. </font>
  <h3>rexp("header","regular-expression")
  <font face="Arial, Helvetica, sans-serif">This function searches the named header
  for a regular expression, the matching is not case sensitive, use rexp_case()
  for a case sensitive version. </font>
  <h3>rexp_fast(spamdetect_score,"regular expression ","comment for spam header")</h3>
  <p><font face="Arial, Helvetica, sans-serif">This is just like rexp, but it
    does the search more efficiently, the first 2 characters of regular expression
    must be plain ascii (not a regular expression) if it's found in the body of
    the message then the score is added to the spam_detect header</font></p>
  <h3>size()</h3>
  <font face="Arial, Helvetica, sans-serif">Returns the size in bytes of the current
  message can be used with > and &lt; operators. </font>
  <h3><a NAME="spamdetect"></a>call
    spamdetect(n,"reason")</h3>
  <font face="Arial, Helvetica, sans-serif"> This function can be used to mark
  a message as possible spam, the 'n' is a (floating-point) number and each time
  this function is called for a message the total is increased, then finally a
  header is added to the message; </font>
  <p> X-SpamDetect: &lt;stars&gt;: &lt;score&gt; &lt;reason1&gt; [reason2 [reason3
    ... ]]<br>
    <br>
    &lt;stars&gt is a string of n stars, where n is the total score (capped at
    20)<br>
    &lt;score&gt is the total spam score<br>
  <p><font face="Arial, Helvetica, sans-serif">The idea is that users can then
    set their mail clients to filter messages based on this pseudo header. For
    instance, filtering any message with "******" in its X-SpamDetect header will
    throw out any message with a score of 6 or more.</font>
  <p>Please note that &quot;local.rul&quot; should be used for adding scoring
    for ASPAM not mfilter.rul.
  <h3><a NAME="spawn"></a>call spawn("program.exe $FILE$")</h3>
  <font face="Arial, Helvetica, sans-serif">This function runs a program on each
  message the $FILE$ macro is replaced by a temporary file name containing the
  actual mail message. The return value of the program (return n; in main() function)
  is returned by this 'spawn' function, so it can be used to filter the message
  or allow it to continue. eg:</font>
  <pre>if (spawn("d:/path/xfilter.exe $FILE$")) reject "That was spam according to xfilter" </pre>
  <p><font face="Arial, Helvetica, sans-serif"><b>NOTE: The mfilter is only passed
    the first 14k of each message, and so the spawned program also only gets the
    first 14k not the entire message.</b></font>
  <p>

  <h2>Actions</h2>
  <h3><a name="accept"></a>accept "reason"</h3>
  <p><font face="Arial, Helvetica, sans-serif">Accepts the current article reporting
    the "reason" specified in the log files. </font></p>
  <h3><a name="clearflag"></a>clearflag("flag-name")</h3>
  <font face="Arial, Helvetica, sans-serif">Used to set the specified flag variable
  to the false state. </font>
  <h3><a name="forward"></a>forward "remote@address.com"</h3>
  <font face="Arial, Helvetica, sans-serif">Forwards the message to the specified
  address and terminates processing. </font>
  <h3><a name="forwardcc"></a>call forward_cc("new@email.address")</h3>
  <font face="Arial, Helvetica, sans-serif">Sends the current message to this
  new Email address in addition to any existing destination users. </font>
  <h3><a name="reject"></a>reject "reason" (or bounce "reason")</h3>
  <font face="Arial, Helvetica, sans-serif">Rejects the current article reporting
  the "reason" specified in the log files and to the user </font>
  <h3><a name="replace"></a>call replace("header_name","wildcard_match_pattern","replacement_pattern")</h3>
  <font face="Arial, Helvetica, sans-serif">If the named header matches the 'wildcard_match_pattern'
  then the replacement pattern is applied, e.g. </font>
  <p><font face="Arial, Helvetica, sans-serif">replace("from","*@*.domain.name","BOB_%1@%2.other.name")
    </font>
  <blockquote><font face="Arial, Helvetica, sans-serif">Subject: "joe@this.domain.name"</font></blockquote>
  <font face="Arial, Helvetica, sans-serif">Would be translated to: </font>
  <blockquote><font face="Arial, Helvetica, sans-serif">Subject: "BOB_joe@this.other.name"</font></blockquote>
  <h3><a name="report"></a>call report("manger@email.address","subject of message")</h3>
  <font face="Arial, Helvetica, sans-serif">Sends an Email, including the top
  part of the offending message, to the specified person, with the specified subject.
  This is intended when you want to be alerted to something but don't want to
  simply forward the message itself which may be 'confusing' as it would look
  like the message had been sent to the manager directly. </font>
  <h3><a name="s"></a>setflag("flag-name")</h3>
  <font face="Arial, Helvetica, sans-serif">Used to set the specified flag variable
  to the true state. <br>
  </font>

  <h2>Regular Expression Syntax - In Brief</h2>
  <p><font face="Arial, Helvetica, sans-serif">Please note you need to escape
    spaces in this implementation.<br>
    eg:</font></p>
  <p>sweepstake lottery / international program<br>
    sweepstake lottery/ international program<br>
    sweepstake lottery /international program</p>
  <p>So what you want is this. Just put slashes in front of the spaces.</p>
  <p> sweepstake lottery( / | /|/ )international program</p>
  <p>if (rexp(&quot;subject&quot;,&quot;sweepstake lottery(\ /\ |\ /|/\ )international
    program&quot;)) bounce &quot;a&quot;</p>
  <p><br>
    <font face="Arial, Helvetica, sans-serif"><b>\s</b> = white space <br>
    <b>\S</b> = not white space <br>
    <b>\d</b> = digit <br>
    <b>\D</b> = not digit <br>
    <b>\b</b> = word boundary <br>
    <b>\B</b> = not word boundary <br>
    <b>\x00</b> = Hex character </font> </p>
  <p><font face="Arial, Helvetica, sans-serif"><b>.</b> (period) represents any
    one character. <br>
    <b>[]</b> (brackets) contain a set of characters from which a match can be
    made. It corresponds to one character in the search string. <br>
    <b>\</b> (backslash) is an escape character which means that the next character
    will not have a special meaning. <br>
    <b>*</b> (asterisk) is a multiplier. It will match zero or more of the previous
    character. (Note: it is not a wildcard character as in file names.) <br>
    <b>?</b> (question mark) is a multiplier. It will match zero or one of the
    previous character. (Note: it is not a wildcard character as in file names.)
    <br>
    <b>+</b> (plus) is a multiplier. It will match one or more of the previous
    character. <br>
    <b>{}</b> (squiggly brackets) contain a number which specifies an exact number
    of the previous character, or range {2,3} <br>
    <b>[^]</b> (brackets containing caret and other characters) means any characters
    except the character(s) after the caret symbol <br>
    in the brackets. <br>
    <b>^</b> (caret) is the start of the line. <br>
    <b>$</b> (dollar) is the end of the line. <br>
    <b>(Note the following \&lt; \> (begin and end word) are not implemented,
    use \b instead)</b> </font>
  <p><font face="Arial, Helvetica, sans-serif"><b>[:alpha:]</b> represents any
    alphabetic letter. <br>
    <b>[:digit:]</b> represents any single-digit number. <br>
    <b>[:blank:]</b> represents a space or tab. </font>
  <p><font face="Arial, Helvetica, sans-serif"><b>Lookahead operator</b> <br>
    Free(?!dom|bsd) matches freesex but not freedom or FreeBSD</font>
  <p><font face="Arial, Helvetica, sans-serif"><b>OR operator</b> <br>
    | (pipe) is OR. It requires that the joined expressions have parentheses around
    them. </font>
  <h4><font face="Arial, Helvetica, sans-serif"> Examples:</font></h4>
  <font face="Arial, Helvetica, sans-serif">e.a matches eta, eda, e1a, but not
  Eta <br>
  [eE].a matches eta and Eta <br>
  E.*a matches Eudora, Etcetera, Ea <br>
  ho+p matches hop, hoop, hoooop, but not hp <br>
  etc\. matches etc. but not etc <br>
  </font>

  <h2><a NAME="Example rule file:"></a>Example rule file:</h2>
  <pre>$sex = "fuck|xxx|sex"
$free = "free(?!dom|bsd|nix|serve)"
$pics = "pi[cx]"
$free_pictures = $free + $pics
$bad_guys = + "|freepictures|jus.?.?\.doi.?.?\.to|great\.site|webbinaries" &#92;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; + "|yad.?.?.?\.ion.?.?\.org|freehidden|joy.?.?\.to.?.?\.al|from.?behind" &#92;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; + "|love(youhon|ergirl|chatting|stofuck)|forever\.yours|\@ju.?.?\.sex|town.\girl|beachbums" \i</pre>
  <pre># Do some processing which is specific to individual recipients
recipients
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (isin("recipient","manager@this.domain")) accept "Always accept for me so spammers can talk to me"
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (isin("recipient","sales@your.domain")) then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (isin("subject","order")) then
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # Make a Duplicate of sale order
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; call forward_cc(<a href="mailto:sales_copy@your.domain">"sales_copy@your.domain"</a>)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end if
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end if
end recipients</pre>
  <pre># Check for some known spammers and naughty subjects
if (rexp(subject,$free_pictures)) bounce "No emails about free pictures"
if (rexp(from,$bad_guys)) bounce "No emails from black listed people thanks"

call replace("From","*@*.parts.co.nz",<a href="mailto:$1@parts.co.nz">"%1@parts.co.nz"</a>)</pre>
  <pre>accept "Great, we liked the message"

</pre>
  <h3>Example 2:</h3>
  <p>We want to block any message that has been found in SURBL database. We will
    use the exists function to check if that header exists.</p>
  <pre>if (exists(&quot;X-Surbl&quot;)) reject &quot;Your SPAM is not wanted here.&quot;</pre>
  <p>You can easily change that to drop the message silently if you prefer <br>
  <pre>if (exists(&quot;X-Surbl&quot;)) drop &quot;SURBL SPAM is not wanted here.&quot; </pre>
  <p>(The reason will be logged so still important to put there)
  <h3>Example 3: </h3>
  <p>We want to block any message with no subject header. SurgeMail adds a subject
    header if it is missing so we have to match on the text that SurgeMail adds.
    <br>
    <pre>if (isin("Subject","(No subject header)")) bounce "No Subject header"</pre>
  <h3>Example 4:</h3>
  <p>We want to block any message with an empty subject header.<br>
    <pre>if (head_len(&quot;Subject&quot;)&lt;1) bounce &quot;Emtpy Subject header&quot;</pre>
  <h3>Example 5:</h3>
  <p>I have a user fred in one of my local domains localdomain.com I only want
    him to be able to send to other users at localdomain.com and not to any other
    domains.</p>
  <pre>recipients
if (isin(&quot;from&quot;,&quot;fred@localdomain.com&quot;)) then
     if (!isin(&quot;recipient&quot;, &quot;localdomain.com&quot;)) bounce &quot;Sorry you can only send to localdomain.com&quot;
end if </pre>
  <p></p>

</font>
<!-- #EndEditable -->
<!-- CONTENT END -->
</div>

<!-- Back to mfilter.htm -->
</div>

<!-- Back to mfilter.htm -->

<div class="prefooter">&nbsp;</div>
<div id="footer" class="footer">
 <table align="center" CELLPADDING="0" CELLSPACING="0" WIDTH="900" HEIGHT="100" BORDER="0" >
  <tr>
    <td HEIGHT="100%" >
      <p align="center" style="margin-top: 8pt; margin-bottom: 2pt; margin-left: 8pt">
  	  <a href="http://netwinsite.com/sitemap.htm" class="footer_link">Site Map</a><span class="style2"> | </span>
  	      <a href="http://netwinsite.com/index.htm" class="footer_link">Home</a><span class="style2"> | </span>
	      <a href="http://netwinsite.com/products.htm" class="footer_link">Products</a><span class="style2"> | </span>
	      <a href="http://netwinsite.com/surgemail/post.htm" class="footer_link">Contact Netwin</a><span class="style2"> | </span>
	      <a href="http://netwinsite.com/company.htm" class="footer_link">Company</a><span class="style2"> | </span>
	      <a href="http://netwinsite.com/license_all.htm" class="footer_link">Licensing</a><span class="style2"> | </span>
	      <a href="http://netwinsite.com/links.htm" class="footer_link">Links</a><span class="style2">  </span>
        <table align=center width="370" border="0" style="margin-bottom: 2pt">
        <tr>
          <td width="32"><img src="template/img2/logo_small_ongray.png" height="25" hspace="1" vspace="1" align="bottom"></td>
          <td width="350"><p class="smaller" style="margin-top: 14pt;">Copyright &copy; 2009 Netwin Ltd. All rights reserved.
		  </td>
        </tr>
      </table>
	</td>
  </tr>
</table>
</div>
</div>

<br><br>
</body>

<!-- Back to mfilter.htm -->

</body>
</html>

<!-- End of mfilter.htm -->
