dejunk - moves an MH/NMH mail message from a junk folder to the inbox


  dejunk [options] <msg1> ... <msgN>


dejunk restores messages from an MH or NMH junk folder to the inbox folder, preferably using the same message number it originally had. If the original message number is already in use, then the restored message will be put at the end of the inbox's messages.

MH and NMH use directories and files for mail folders and mail messages, with everything for a user being stored in either ~/mail or ~/Mail. (Other directories are possible, but these are the most common.) Each mail folder is its own subdirectory. Each individual mail message is stored in its own file whose name is the message's number in its mailbox.

In most cases, deleting a message (with the rmm command) doesn't actually delete the message, but instead prepends a comma to the message's file name. The comma informs MH not to consider that an "active" mail message. Similarly, when a message is refiled from one folder to another, a copy remains in the original folder but it has a comma prepended to its name.

In restoring a message to the inbox, the junk message will be compared to the "deleted" inbox files in an attempt to find the original message number. File checksums are compared in order to find the original "deleted" file.

When specifying messages to restore, dejunk distinguishes between "deleted" junk messages (those with a comma prepended to the message number) and junk messages that haven't been deleted. In practical terms, this means that the actual file name in the junk folder must be given on the command line -- "dejunk ,12" and "dejunk 12" will act on different messages.

dejunk tries to restore a junk message to the same message number it had when it was junked. If that message number is already in use in the inbox, then the message will be moved to the end of the inbox's message list. There are three cases for restored files:


dejunk takes the following options:


Copyright 2014 Wayne Morrison

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.


Wayne Morrison,


cksum(1), inc(1), nmh(1), refile(1), rmm(1)