diff --git a/exec/load/mailproc_util.js b/exec/load/mailproc_util.js
new file mode 100644
index 0000000000000000000000000000000000000000..639c8b88d64db25612627a3ac8d108417b4312ee
--- /dev/null
+++ b/exec/load/mailproc_util.js
@@ -0,0 +1,22 @@
+// mailproc_util.js
+
+// Utility functions for Synchronet external mail processors
+
+// $Id$
+
+// Parses raw RFC822-formatted messages for use with SMTP Mail Processors
+// Returns an array of header fields parsed from the msgtxt
+// msgtxt is an array of lines from the source (RFC822) message text
+function parse_msg_header(msgtxt)
+{
+	var hdr={};
+
+	for(i in msgtxt) {
+		if(msgtxt[i].length==0)	/* Header delimiter */
+			break;
+		var match = msgtxt[i].match(/\s*(\S+)\s*:\s*(.*)/);
+		hdr[match[0]]=match[1];
+	}	
+		
+	return(hdr);
+}
\ No newline at end of file
diff --git a/exec/mailproc_example.js b/exec/mailproc_example.js
index 2ac8bcf423e9cce7daf8e741ea8ade8906ec425f..69e6f2c3a18dd99d3d81fe31c009b8f5db93d250 100644
--- a/exec/mailproc_example.js
+++ b/exec/mailproc_example.js
@@ -5,6 +5,8 @@
 
 // $Id$
 
+load("mailproc_util.js");
+
 // Set to false at any time to indicate a processing failure
 var success=true;
 
@@ -25,19 +27,27 @@ var recipient=rcptlst.iniGetAllObjects("number");
 
 // These lines open the message text file in append mode (writing to the end)
 var msgtxt = new File(message_text_filename);
-if(!msgtxt.open("a"))	// Change thie mode to "r+" for "read/update" access
+if(!msgtxt.open("a+"))	// Change the mode to "r+" for "read/update" access
 	exit();
 
+// Create an object (associative array) of header field strings
+var header = parse_msg_header(msgtxt.readAll());
+
 // This an example of modifying the message text.
 // In this case, we're adding some text (a dump of the recipient object array)
 // to the end of the message.
-msgtxt.writeln("\r\nHello from mailproc_example.js\r\n");
-msgtxt.writeln("Array of recipient objects (message envelopes):\r\n");
+msgtxt.writeln("\r\nHello from mailproc_example.js");
 
 // Dump recipient object array
+msgtxt.writeln("\r\nArray of recipient objects (message envelopes):\r\n");
 for(i in recipient)			// For each recipient object...
 	for(j in recipient[i])	// For each property...			
-		msgtxt.writeln("recipient[" +i+ "]." +j+ "=" + recipient[i][j]);
+		msgtxt.writeln("recipient[" +i+ "]." +j+ " = " + recipient[i][j]);
+
+// Dump header field strings
+msgtxt.writeln("\r\nArray of RFC822 header fields:\r\n");
+for(i in header)
+	msgtxt.writeln("header." +i+ " = " + header[i]);
 
 // If there were any processing errors... reject the message
 if(!success)