diff -urN clamav-devel.jm-pl1/clamav-milter/clamav-milter.c clamav-devel.jm-pl2/clamav-milter/clamav-milter.c
--- clamav-devel.jm-pl1/clamav-milter/clamav-milter.c	Tue Apr 27 14:04:14 2004
+++ clamav-devel.jm-pl2/clamav-milter/clamav-milter.c	Tue Apr 27 14:05:40 2004
@@ -2160,7 +2160,7 @@
 			return cl_error;
 		}
 
-		snprintf(cmdbuf, sizeof(cmdbuf) - 1, "SCAN %s", privdata->filename);
+		snprintf(cmdbuf, sizeof(cmdbuf) - 1, "MAILSCAN %s", privdata->filename);
 
 		nbytes = (int)strlen(cmdbuf);
 
@@ -3017,7 +3017,7 @@
 
 		shutdown(privdata->dataSocket, SHUT_RD);
 
-		if(send(privdata->cmdSocket, "STREAM\n", 7, 0) < 7) {
+		if(send(privdata->cmdSocket, "MAILSTREAM\n", 11, 0) < 7) {
 			perror("send");
 			if(use_syslog)
 				syslog(LOG_ERR, "send failed to clamd");
diff -urN clamav-devel.jm-pl1/clamd/session.c clamav-devel.jm-pl2/clamd/session.c
--- clamav-devel.jm-pl1/clamd/session.c	Tue Apr 27 14:04:14 2004
+++ clamav-devel.jm-pl2/clamd/session.c	Tue Apr 27 14:05:40 2004
@@ -54,6 +54,9 @@
 #define CMD9 "SESSION"
 #define CMD10 "END"
 #define CMD11 "SHUTDOWN"
+#define CMD12 "MAILSTREAM"
+#define CMD13 "MAILSCAN"
+#define CMD14 "CONTMAILSCAN"
 
 
 int command(int desc, const struct cl_node *root, const struct cl_limits *limits, int options, const struct cfgstruct *copt)
@@ -150,6 +153,27 @@
     } else if(!strncmp(buff, CMD11, strlen(CMD11))) { /* SHUTDOWN */
 	return COMMAND_QUIT;
 
+    } else if(!strncmp(buff, CMD12, strlen(CMD12))) { /* MAILSTREAM */
+	if((cpt = cfgopt(copt,"ScanMail"))) {
+	    options |= CL_UNKNOWN_MAIL;
+	    scanstream(desc, NULL, root, limits, options, copt);
+	} else {
+	    mdprintf(desc, "UNKNOWN COMMAND\n");
+	}
+    } else if(!strncmp(buff, CMD13, strlen(CMD13))) { /* MAILSCAN */
+	if((cpt = cfgopt(copt,"ScanMail"))) {
+	    options |= CL_UNKNOWN_MAIL;
+	    scan(buff + strlen(CMD13) + 1, NULL, root, limits, options, copt, desc, 0);
+	} else {
+	    mdprintf(desc, "UNKNOWN COMMAND\n");
+	}
+    } else if(!strncmp(buff, CMD14, strlen(CMD14))) { /* CONTMAILSCAN */
+	if((cpt = cfgopt(copt,"ScanMail"))) {
+	    options |= CL_UNKNOWN_MAIL;
+	    scan(buff + strlen(CMD14) + 1, NULL, root, limits, options, copt, desc, 1);
+	} else {
+	    mdprintf(desc, "UNKNOWN COMMAND\n");
+	}
     } else {
 	mdprintf(desc, "UNKNOWN COMMAND\n");
     }
diff -urN clamav-devel.jm-pl1/clamdscan/clamdscan.c clamav-devel.jm-pl2/clamdscan/clamdscan.c
--- clamav-devel.jm-pl1/clamdscan/clamdscan.c	Tue Apr 27 14:04:14 2004
+++ clamav-devel.jm-pl2/clamdscan/clamdscan.c	Tue Apr 27 14:05:40 2004
@@ -126,6 +126,8 @@
     mprintf("    --verbose           -v             Be verbose\n");
     mprintf("    --quiet                            Be quiet, only output error messages\n");
     mprintf("    --stdout                           Write to stdout instead of stderr\n");
+    mprintf("    --mail, --mbox-force, -M           All unknown file type will be a RFC822 mail file\n");
+    mprintf("    --stdout                           Write to stdout instead of stderr\n");
     mprintf("                                       (this help is always written to stdout)\n");
     mprintf("    --log=FILE          -l FILE        Save scan report in FILE\n");
     mprintf("    --log-verbose                      Log additional messages\n");
diff -urN clamav-devel.jm-pl1/clamdscan/client.c clamav-devel.jm-pl2/clamdscan/client.c
--- clamav-devel.jm-pl1/clamdscan/client.c	Tue Apr 27 14:04:14 2004
+++ clamav-devel.jm-pl2/clamdscan/client.c	Tue Apr 27 14:05:40 2004
@@ -55,6 +55,7 @@
 	int sockd, wsockd, loopw = 60, bread, port;
 	const char *clamav_conf = getargl(opt, "config-file");
 	FILE *fd;
+	short unknown_mail = 0;
 
     if(!clamav_conf)
 	clamav_conf = DEFAULT_CFG;
@@ -64,6 +65,15 @@
 	return 2;
     }
 
+     if((cfgopt(copt, "ScanMail")) &&
+	(
+	    (optl(opt, "mbox-force")) ||
+	    (optl(opt, "mail")) ||
+	    (optc(opt, 'M'))
+         )
+        ) 
+	unknown_mail = 1;	    
+
     /* Set default address to connect to; needed for scanning a stream and no TCP address specified */
     server2.sin_addr.s_addr = inet_addr("127.0.0.1");    
     if(cfgopt(copt, "ScannerDaemonOutputFormat")) {
@@ -137,7 +147,7 @@
 	file = (char *) strdup(cwd);
 
     } else if(!strcmp(opt->filename, "-")) { /* scan data from stdin */
-	if(write(sockd, "STREAM", 6) <= 0) {
+	if(write(sockd, (unknown_mail) ? "MAILSTREAM" : "STREAM", (unknown_mail) ? 10 : 6) <= 0) {
 	    mprintf("@Can't write to the socket.\n");
 	    close(sockd);
 	    return 2;
@@ -229,7 +239,7 @@
 
 
     scancmd = mcalloc(strlen(file) + 20, sizeof(char));
-    sprintf(scancmd, "CONTSCAN %s", file);
+    sprintf(scancmd, "%s %s", (unknown_mail)? "CONTMAILSCAN" : "CONTSCAN", file);
     free(file);
 
     if(write(sockd, scancmd, strlen(scancmd)) <= 0) {
diff -urN clamav-devel.jm-pl1/clamscan/clamscan.c clamav-devel.jm-pl2/clamscan/clamscan.c
--- clamav-devel.jm-pl1/clamscan/clamscan.c	Tue Apr 27 14:04:14 2004
+++ clamav-devel.jm-pl2/clamscan/clamscan.c	Tue Apr 27 14:05:40 2004
@@ -208,6 +208,10 @@
     mprintf("    --bell                               Sound bell on virus detection\n");
     mprintf("    --no-summary                         Disable summary at end of scanning\n");
     mprintf("    --mbox                -m             Treat stdin as a mailbox\n");
+    mprintf("    --mbox-force          -M\n");
+    mprintf("    --mail                -M             Unrecognized filetypes  will be be treated\n");
+    mprintf("                                         as RFC822 mail file.\n");
+    mprintf("                                         This implies --mbox (-m)\n");
     mprintf("\n");
     mprintf("    --no-ole2                            Disable OLE2 support\n");
     mprintf("    --no-archive                         Disable libclamav archive support\n");
diff -urN clamav-devel.jm-pl1/clamscan/manager.c clamav-devel.jm-pl2/clamscan/manager.c
--- clamav-devel.jm-pl1/clamscan/manager.c	Tue Apr 27 14:04:14 2004
+++ clamav-devel.jm-pl2/clamscan/manager.c	Tue Apr 27 14:05:40 2004
@@ -373,6 +373,12 @@
     if(optc(opt, 'm'))
 	options |= CL_MAIL;
 
+    if(optc(opt, 'M') || optl(opt,"mail")) {
+	options |= CL_MAIL;
+	options |= CL_UNKNOWN_MAIL;
+    }
+	
+
     /* 
      * check the extension  - this is a special case, normally we don't need to
      * do this (libclamav detects archive by its magic string), but here we
diff -urN clamav-devel.jm-pl1/clamscan/options.c clamav-devel.jm-pl2/clamscan/options.c
--- clamav-devel.jm-pl1/clamscan/options.c	Tue Apr 27 14:04:14 2004
+++ clamav-devel.jm-pl2/clamscan/options.c	Tue Apr 27 14:05:40 2004
@@ -43,7 +43,7 @@
 	int ret, opt_index, i, len;
 	struct optstruct *opt;
 
-	const char *getopt_parameters = "hvd:wriVl:m";
+	const char *getopt_parameters = "hvd:wriVl:mM";
 
 	static struct option long_options[] = {
 	    /* 
@@ -82,6 +82,8 @@
 	    {"block-encrypted", 0, 0, 0},
 	    {"no-ole2", 0, 0, 0},
 	    {"mbox", 0, 0, 'm'},
+	    {"mbox-force", 0, 0, 'M'},
+	    {"mail", 0, 0, 0},
 	    {"stdout", 0, 0, 0},
 	    {"unzip", 2, 0, 0},
 	    {"unrar", 2, 0, 0},
diff -urN clamav-devel.jm-pl1/docs/man/clamav.conf.5 clamav-devel.jm-pl2/docs/man/clamav.conf.5
--- clamav-devel.jm-pl1/docs/man/clamav.conf.5	Tue Apr 27 14:04:14 2004
+++ clamav-devel.jm-pl2/docs/man/clamav.conf.5	Tue Apr 27 14:08:30 2004
@@ -169,6 +169,11 @@
 .br 
 Default: disabled.
 .TP 
+\fBScanUnknownAsMail\fR
+If ScanMail is enabled, and we cannot recognize the file type, treat it as a Mbox, Maildir or raw mail file.
+.br 
+Default: disabled.
+.TP 
 \fBScanArchive\fR
 Enable archive scanning.
 .br 
diff -urN clamav-devel.jm-pl1/docs/man/clamdscan.1 clamav-devel.jm-pl2/docs/man/clamdscan.1
--- clamav-devel.jm-pl1/docs/man/clamdscan.1	Tue Apr 27 14:04:14 2004
+++ clamav-devel.jm-pl2/docs/man/clamdscan.1	Tue Apr 27 14:15:21 2004
@@ -5,7 +5,7 @@
 clamdscan \- scan files and directories against viruses using Clam AntiVirus Daemon
 .SH "SYNOPSIS"
 .LP 
-clamdscan [options] [file/directory]
+clamdscan [options] [file/directory] [-]
 .SH "DESCRIPTION"
 .LP 
 clamdscan is a simple clamd client which may be used as a clamscan replacement. clamdscan accepts all the options implemented in clamscan but most of them will be ignored because its scanning abilities only depend on clamd. clamdscan is a part of the Clam AntiVirus package.
@@ -33,7 +33,10 @@
 .TP 
 \fB\-l FILE, \-\-log=FILE\fR
 Save the scan report to FILE.
-.TP 
+.TP
+\fB\-M, \-\-mail, \-\-mbox-force\fR
+Use protocol commands to clamd to request mbox mode on to be scanned content, if it is unrecognized by clamd. 
+.TP
 \fB\-\-log\-verbose\fR
 Save additional messages (mostly useless) to the report file.
 .TP 
@@ -53,6 +56,11 @@
 (2) To scan all files in /home:
 
 \fBclamdscan /home\fR
+.TP
+(3) To scan standard in (stream):
+
+\fBcat myfile | clamdscan -\fR
+
 .SH "RETURN CODES"
 .LP 
 0 : No virus found.
diff -urN clamav-devel.jm-pl1/docs/man/clamscan.1 clamav-devel.jm-pl2/docs/man/clamscan.1
--- clamav-devel.jm-pl1/docs/man/clamscan.1	Tue Apr 27 14:04:14 2004
+++ clamav-devel.jm-pl2/docs/man/clamscan.1	Tue Apr 27 14:16:44 2004
@@ -57,6 +57,9 @@
 .TP 
 \fB\-\-mbox\fR
 Enable scanning of various mail file types (also treat stdin as a mailbox \- for backward compatibility).
+.TP
+\fB\-M, \-\-mail, \-\-mbox-force\fR
+Request mbox mode on to be scanned content, if it is unrecognized by libclamav. This implies \-\-mbox. 
 .TP 
 \fB\-i, \-\-infected\fR
 Only print infected files.
diff -urN clamav-devel.jm-pl1/libclamav/clamav.h clamav-devel.jm-pl2/libclamav/clamav.h
--- clamav-devel.jm-pl1/libclamav/clamav.h	Tue Apr 27 14:04:14 2004
+++ clamav-devel.jm-pl2/libclamav/clamav.h	Tue Apr 27 14:05:40 2004
@@ -69,6 +69,7 @@
 #define CL_DISABLERAR	4
 #define CL_OLE2		8
 #define CL_ENCRYPTED    16
+#define CL_UNKNOWN_MAIL	32
 
 struct cli_patt {
     short int *pattern;
diff -urN clamav-devel.jm-pl1/libclamav/scanners.c clamav-devel.jm-pl2/libclamav/scanners.c
--- clamav-devel.jm-pl1/libclamav/scanners.c	Tue Apr 27 14:04:14 2004
+++ clamav-devel.jm-pl2/libclamav/scanners.c	Tue Apr 27 14:05:40 2004
@@ -58,6 +58,7 @@
 #define SCAN_OLE2	    (options & CL_OLE2)
 #define DISABLE_RAR	    (options & CL_DISABLERAR)
 #define DETECT_ENCRYPTED    (options & CL_ENCRYPTED)
+#define SCAN_UNKNOWN_MAIL    (options & CL_UNKNOWN_MAIL)
 
 struct cli_magic_s {
     int offset;
@@ -884,6 +885,9 @@
     }
 
     type = cli_filetype(magic, bread);
+
+	if(type == CL_UNKNOWN_TYPE && SCAN_UNKNOWN_MAIL)
+		type = CL_MAILFILE;
 
     switch(type) {
 	case CL_RARFILE:
diff -urN clamav-devel.jm-pl1/shared/cfgparser.c clamav-devel.jm-pl2/shared/cfgparser.c
--- clamav-devel.jm-pl1/shared/cfgparser.c	Tue Apr 27 14:04:14 2004
+++ clamav-devel.jm-pl2/shared/cfgparser.c	Tue Apr 27 14:05:40 2004
@@ -62,6 +62,7 @@
 	    {"TemporaryDirectory", OPT_STR},
 	    {"MaxFileSize", OPT_COMPSIZE},
 	    {"ScanMail", OPT_NOARG},
+	    {"ScanUnknownAsMail", OPT_NOARG},
 	    {"ScanOLE2", OPT_NOARG},
 	    {"ScanArchive", OPT_NOARG},
 	    {"ScanRAR", OPT_NOARG},
