{
    "mode": "man",
    "parameter": "mhfixmsg",
    "section": "1mh",
    "url": "https://www.chedong.com/phpMan.php/man/mhfixmsg/1mh/json",
    "generated": "2026-05-30T05:14:40Z",
    "synopsis": "mhfixmsg [-help] [-version] [+folder] [msgs | absolute pathname | -file file] [-decodetext\n8bit|7bit|binary | -nodecodetext] [-decodetypes type/[subtype][,...]]  [-crlflinebreaks\n| -nocrlflinebreaks] [-textcharset charset | -notextcharset] [-reformat | -noreformat]\n[-replacetextplain | -noreplacetextplain] [-fixboundary | -nofixboundary] [-fixcte |\n-nofixcte] [-fixtype mimetype] [-outfile outfile] [-rmmproc program] [-normmproc]\n[-changecur | -nochangecur] [-verbose | -noverbose]",
    "sections": {
        "NAME": {
            "content": "mhfixmsg - nmh's MIME-email rewriter with various transformations\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "mhfixmsg [-help] [-version] [+folder] [msgs | absolute pathname | -file file] [-decodetext\n8bit|7bit|binary | -nodecodetext] [-decodetypes type/[subtype][,...]]  [-crlflinebreaks\n| -nocrlflinebreaks] [-textcharset charset | -notextcharset] [-reformat | -noreformat]\n[-replacetextplain | -noreplacetextplain] [-fixboundary | -nofixboundary] [-fixcte |\n-nofixcte] [-fixtype mimetype] [-outfile outfile] [-rmmproc program] [-normmproc]\n[-changecur | -nochangecur] [-verbose | -noverbose]\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "mhfixmsg rewrites MIME messages, applying specific transformations such as decoding of  MIME-\nencoded message parts and repairing invalid MIME headers.\n\nMIME  messages are specified in RFC 2045 to RFC 2049 (see mhbuild(1)).  The mhlist command is\ninvaluable for viewing the content structure of MIME messages.  mhfixmsg passes non-MIME mes‐\nsages  through  without  any transformations.  If no transformations apply to a MIME message,\nthe original message or file is not modified or removed.  Thus, mhfixmsg can  safely  be  run\nmultiple times on a message.\n\nThe  -decodetext  switch  enables a transformation to decode each base64 and quoted-printable\ntext message part to the selected 8-bit, 7-bit, or binary encoding.  If 7-bit is selected for\na  base64 part but it will only fit 8-bit, as defined by RFC 2045, then it will be decoded to\n8-bit quoted-printable.  Similarly, with 8-bit, if the decoded text would be binary, then the\npart is not decoded (and a message will be displayed if -verbose is enabled).  Note that -de‐‐\ncodetext binary can produce messages that are not RFC 2045 compliant.\n\nWhen the -decodetext switch is enabled, each carriage return character that precedes a  line‐\nfeed  character  is  removed  from  text  parts  encoded in ASCII, ISO-8859-x, UTF-8, or Win‐\ndows-12xx.\n\nThe -decodetypes switch specifies the message parts, by type and optionally subtype, to which",
            "subsections": [
                {
                    "name": "-decodetext",
                    "content": "element does not contain a subtype, then -decodetext applies to all  subtypes  of  the  type.\nThe default is -decodetypes text; it can be overridden, e.g., with -decodetypes text/plain to\nrestrict -decodetext to just text/plain parts.\n\nBy default, carriage return characters are preserved or inserted at the end of each  line  of\ntext  content.   The  -crlflinebreaks switch selects this behavior and is enabled by default.\nThe -nocrlflinebreaks switch causes carriage return characters to be stripped from,  and  not\ninserted  in,  text  content when it is decoded and encoded.  Note that its use can cause the\ngeneration of MIME messages that do not conform to RFC 2046, §4.1.1, paragraph 1.\n\nThe -textcharset switch specifies that all text/plain parts of the message(s) should be  con‐\nverted  to charset.  Charset conversions require that nmh be built with iconv(3); see the mh‐‐\nparam(1) man page for how determine whether your nmh installation includes that.  To  convert\ntext parts other than text/plain, an external program can be used, via the -reformat switch.\n\nThe  -reformat  switch enables a transformation for text parts in the message.  For each text\npart that is not text/plain and that does not have a corresponding  text/plain  in  a  multi‐\npart/alternative  part,  mhfixmsg looks for a mhfixmsg-format-text/subtype profile entry that\nmatches the subtype of the part.  If one is found and can be used to successfully convert the\npart  to text/plain, mhfixmsg inserts that text/plain part at the beginning of the containing\nmultipart/alternative part, if present.  If not, it creates a multipart/alternative part.\n\nWith the -reformat switch, multipart/related parts are handled differently than multipart/al‐\nternative.  If the multipart/related has only a single part that is not text/plain and can be\nconverted to text/plain, a text/plain part is added and the type of the part  is  changed  to\nmultipart/alternative.   If  the multipart/related has more than one part but does not have a\ntext/plain part, mhfixmsg tries to add one.\n\nThe -replacetextplain switch broadens the applicability of -reformat, by always  replacing  a\ncorresponding  text/plain  part, if one exists.  If -verbose is enabled, the replacement will\nbe shown as two steps:  a removal of the text/plain part, followed by the usual insertion  of\na new part.\n"
                },
                {
                    "name": "-reformat",
                    "content": "fixmsg-format-text/subtype profile entries are based on external conversion programs, and are\nused  in the same way that mhshow uses its mhshow-show-text/subtype entries.  When nmh is in‐\nstalled, it searches for a conversion program for text/html content, and if one is found, in‐\nserts  a mhfixmsg-format-text/html entry in /etc/nmh/mhn.defaults.  An entry of the same name\nin the user's profile takes precedence.  The user can add entries for other text subtypes  to\ntheir profile.\n\nThe  -fixboundary  switch enables a transformation to repair the boundary portion of the Con‐\ntent-Type header field of the message to match the boundaries of the outermost multipart part\nof the message, if it does not.  That condition is indicated by a “bogus multipart content in\nmessage” error message from mhlist and other nmh programs that parse MIME messages.\n\nThe -fixcte switch enables a transformation to change the Content-Transfer-Encoding  from  an\ninvalid  value to 8-bit in message parts with a Content-Type of multipart and message, as re‐\nquired by RFC 2045, §6.4.  That condition is indicated by a “must be encoded in  7bit,  8bit,\nor binary” error message from mhlist and other nmh programs that parse MIME messages.\n\nThe  -fixtype switch ensures that each part of the message has the correct MIME type shown in\nits Content-Type header.  It may be repeated.  It is  typically  used  to  replace  “applica‐\ntion/octet-stream”  with  a more descriptive MIME type.  It may not be used for multipart and\nmessage types.\n\nmhfixmsg applies two transformations unconditionally.  The first removes an extraneous trail‐\ning  semicolon from the parameter lists of MIME header field values.  The second replaces RFC\n2047 encoding with RFC 2231 encoding of name and filename parameters in Content-Type and Con‐\ntent-Disposition header field values, respectively.\n\nThe  -verbose switch directs mhfixmsg to output informational message for each transformation\napplied.\n\nThe return status of mhfixmsg is 0 if all of the requested transformations are performed,  or\nnon-zero otherwise.  (mhfixmsg will not decode to binary content with the default -decodetext\nsetting, but a request to do so is not considered a failure, and is noted with -verbose.)  If\na  problem  is detected with any one of multiple messages such that the return status is non-\nzero, then none of the messages will be modified.\n\nThe -file file switch directs mhfixmsg to use the  specified  file  as  the  source  message,\nrather  than  a  message  from  a folder.  Only one file argument may be provided.  The -file\nswitch is implied if file is an absolute pathname.  If the file is “-”, then mhfixmsg accepts\nthe  source message on the standard input stream.  If the -outfile switch is not enabled when\nusing the standard input stream, mhfixmsg will not produce a transformed output message.\n\nmhfixmsg, by default, transforms the message in place.  If the -outfile  switch  is  enabled,\nthen mhfixmsg does not modify the input message or file, but instead places its output in the\nspecified file.  An outfile name of “-” specifies the standard output stream.\n\nCombined with the -verbose switch, the -outfile switch can be used to show  what  transforma‐\ntions mhfixmsg would apply without actually applying them, e.g.,\n\nmhfixmsg -outfile /dev/null -verbose\n\nAs always, this usage obeys any mhfixmsg switches in the user's profile.\n"
                },
                {
                    "name": "-outfile",
                    "content": "folder, e.g.,\n\nmhfixmsg -outfile - | \\\n/usr/lib/mh/rcvstore +folder\n"
                },
                {
                    "name": "Summary of Applicability",
                    "content": "The transformations apply to the parts of a message depending on content type and/or encoding\nas follows:\n\n-decodetext         base64 and quoted-printable encoded text parts\n-decodetypes        limits parts to which -decodetext applies\n-crlflinebreaks     text parts\n-textcharset        text/plain parts\n-reformat           text parts that are not text/plain\n-fixboundary        outermost multipart part\n-fixcte             multipart or message part\n-fixtype            all except multipart and message parts\n"
                },
                {
                    "name": "Backup of Original Message/File",
                    "content": "If  it applies any transformations to a message or file, and the -outfile switch is not used,\nmhfixmsg backs up the original the same way as rmm.  That is, it  uses  the  rmmproc  profile\ncomponent, if present.  If not present, mhfixmsg moves the original message to a backup file.\nThe -rmmproc switch may be used to override this profile component.   The  -normmproc  switch\ndisables the use of any rmmproc profile component and negates all prior -rmmproc switches.\n"
                },
                {
                    "name": "Integration with inc",
                    "content": "mhfixmsg  can  be used as an add-hook, as described in /usr/share/doc/nmh/README-HOOKS.  Note\nthat add-hooks are called from all nmh programs that add a message to a folder, not just inc.\nAlternatively,  a simple shell alias or function can be used to call mhfixmsg immediately af‐\nter a successful invocation of inc.  One approach could be based on:\n\nmsgs=`inc -format '%(msg)'`  &&  [ -n \"$msgs\" ]  &&  scan $msgs  &&  mhfixmsg -nochange‐\ncur $msgs\n\nAnother  approach would rely on adding a sequence to Unseen-Sequence, which inc sets with the\nnewly incorporated messages.  Those could then be supplied to mhfixmsg.  An example is  shown\nbelow.\n"
                },
                {
                    "name": "Integration with procmail",
                    "content": "By  way  of  example, here is an excerpt from a procmailrc file that filters messages through\nmhfixmsg before storing them in the user's nmh-workers folder.  It also stores  the  incoming\nmessage  in the Backups folder in a filename generated by mkstemp, which is a non-POSIX util‐\nity to generate a temporary file.  Alternatively, mhfixmsg could be called on the message af‐\nter it is stored.\n\nPATH = /usr/bin/mh:$PATH\nLANG = enUS.utf8\nMAILDIR = `mhparam path`\n#### The Backups directory is relative to MAILDIR.\nMKSTEMP = 'mkstemp -directory Backups -prefix mhfixmsg'\nMHFIXMSG = 'mhfixmsg -noverbose -file - -outfile -'\nSTORE = /usr/lib/mh/rcvstore\n\n:0 w: nmh-workers/procmail.$LOCKEXT\n* ^TOnmh-workers@nongnu.org\n| tee `$MKSTEMP` | $MHFIXMSG | $STORE +nmh-workers\n"
                }
            ]
        },
        "EXAMPLES": {
            "content": "",
            "subsections": [
                {
                    "name": "Basic usage",
                    "content": "To run mhfixmsg on the current message in the current folder, with default transformations to\nfix MIME boundaries and Content-Transfer-Encoding, to decode text and application/ics content\nparts to 8 bit, and to add a corresponding text/plain part where lacking:\n\nmhfixmsg -verbose\n"
                },
                {
                    "name": "Specified folder and messages",
                    "content": "To run mhfixmsg on specified messages, without its informational output:\n\nmhfixmsg +inbox last:4\n"
                },
                {
                    "name": "View without modification",
                    "content": "By  default, mhfixmsg transforms the message in place.  To view the MIME structure that would\nresult from running mhfixmsg on the current message, without modifying the message:\n\nmhfixmsg -outfile - | mhlist -file -\n"
                },
                {
                    "name": "Search message without modification",
                    "content": "To search the current message, which possibly contains base64  or  quoted  printable  encoded\ntext parts, without modifying it, use the -outfile switch:\n\nmhfixmsg -outfile - | grep pattern\n"
                },
                {
                    "name": "-outfile",
                    "content": "tire message, not just text parts.\n"
                },
                {
                    "name": "Translate text/plain parts to UTF-8",
                    "content": "To translate all text/plain parts in the current message to UTF-8, in addition to all of  the\ndefault transformations:\n\nmhfixmsg -textcharset utf-8\n"
                },
                {
                    "name": "Fix all messages in a folder",
                    "content": "To run mhfixmsg on all of the messages in a folder:\n\nmhfixmsg +folder all\n\nAlternatively,  mhfixmsg  can  be  run on each message separately, e.g., using a Bourne shell\nloop:\n\nfor msg in `pick +folder`; do mhfixmsg +folder $msg; done\n\nThe two appearances of the +folder switch in that command protect against concurrent  context\nchanges by other nmh command invocations.\n"
                },
                {
                    "name": "Run on newly incorporated messages",
                    "content": "To run mhfixmsg on messages as they are incorporated:\n\ninc  &&  mhfixmsg -nochangecur unseen\n\nThis  assumes  that  the  Unseen-Sequence profile entry is set to unseen, as shown in mh-pro‐\nfile(5).\n"
                }
            ]
        },
        "FILES": {
            "content": "mhfixmsg looks for mhn.defaults in multiple locations: absolute pathnames  are  accessed  di‐\nrectly,  tilde  expansion is done on usernames, and files are searched for in the user's Mail\ndirectory as specified in their profile.  If not found there,  the  directory  “/etc/nmh”  is\nchecked.\n\n$HOME/.mhprofile      The user profile\n/etc/nmh/mhn.defaults  Default mhfixmsg conversion entries\n",
            "subsections": []
        },
        "PROFILE COMPONENTS": {
            "content": "Path:                To determine the user's nmh directory\nCurrent-Folder:      To find the default current folder\nrmmproc:             Program to delete original messages or files\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "iconv(3), inc(1), mh-mkstemp(1), mh-profile(5), mhbuild(1), mhlist(1), mhparam(1), mhshow(1),\nprocmail(1), procmailrc(5), rcvstore(1), rmm(1)\n",
            "subsections": []
        },
        "DEFAULTS": {
            "content": "`+folder' defaults to the current folder\n`msgs' defaults to cur\n`-decodetext 8bit'\n`-decodetypes text,application/ics'\n`-crlflinebreaks'\n`-notextcharset'\n`-reformat'\n`-noreplacetextplain'\n`-fixboundary'\n`-fixcte'\n`-changecur'\n`-noverbose'\n",
            "subsections": []
        },
        "CONTEXT": {
            "content": "If a folder is given, it will become the current folder.  The last message  selected  from  a\nfolder  will  become  the current message, unless the -nochangecur switch is enabled.  If the",
            "subsections": [
                {
                    "name": "-file",
                    "content": "nmh-1.7.1                                    2016-11-08                                MHFIXMSG(1mh)"
                }
            ]
        }
    },
    "summary": "mhfixmsg - nmh's MIME-email rewriter with various transformations",
    "flags": [
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "element does not contain a subtype, then -decodetext applies to all subtypes of the type. The default is -decodetypes text; it can be overridden, e.g., with -decodetypes text/plain to restrict -decodetext to just text/plain parts. By default, carriage return characters are preserved or inserted at the end of each line of text content. The -crlflinebreaks switch selects this behavior and is enabled by default. The -nocrlflinebreaks switch causes carriage return characters to be stripped from, and not inserted in, text content when it is decoded and encoded. Note that its use can cause the generation of MIME messages that do not conform to RFC 2046, §4.1.1, paragraph 1. The -textcharset switch specifies that all text/plain parts of the message(s) should be con‐ verted to charset. Charset conversions require that nmh be built with iconv(3); see the mh‐‐ param(1) man page for how determine whether your nmh installation includes that. To convert text parts other than text/plain, an external program can be used, via the -reformat switch. The -reformat switch enables a transformation for text parts in the message. For each text part that is not text/plain and that does not have a corresponding text/plain in a multi‐ part/alternative part, mhfixmsg looks for a mhfixmsg-format-text/subtype profile entry that matches the subtype of the part. If one is found and can be used to successfully convert the part to text/plain, mhfixmsg inserts that text/plain part at the beginning of the containing multipart/alternative part, if present. If not, it creates a multipart/alternative part. With the -reformat switch, multipart/related parts are handled differently than multipart/al‐ ternative. If the multipart/related has only a single part that is not text/plain and can be converted to text/plain, a text/plain part is added and the type of the part is changed to multipart/alternative. If the multipart/related has more than one part but does not have a text/plain part, mhfixmsg tries to add one. The -replacetextplain switch broadens the applicability of -reformat, by always replacing a corresponding text/plain part, if one exists. If -verbose is enabled, the replacement will be shown as two steps: a removal of the text/plain part, followed by the usual insertion of a new part."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "fixmsg-format-text/subtype profile entries are based on external conversion programs, and are used in the same way that mhshow uses its mhshow-show-text/subtype entries. When nmh is in‐ stalled, it searches for a conversion program for text/html content, and if one is found, in‐ serts a mhfixmsg-format-text/html entry in /etc/nmh/mhn.defaults. An entry of the same name in the user's profile takes precedence. The user can add entries for other text subtypes to their profile. The -fixboundary switch enables a transformation to repair the boundary portion of the Con‐ tent-Type header field of the message to match the boundaries of the outermost multipart part of the message, if it does not. That condition is indicated by a “bogus multipart content in message” error message from mhlist and other nmh programs that parse MIME messages. The -fixcte switch enables a transformation to change the Content-Transfer-Encoding from an invalid value to 8-bit in message parts with a Content-Type of multipart and message, as re‐ quired by RFC 2045, §6.4. That condition is indicated by a “must be encoded in 7bit, 8bit, or binary” error message from mhlist and other nmh programs that parse MIME messages. The -fixtype switch ensures that each part of the message has the correct MIME type shown in its Content-Type header. It may be repeated. It is typically used to replace “applica‐ tion/octet-stream” with a more descriptive MIME type. It may not be used for multipart and message types. mhfixmsg applies two transformations unconditionally. The first removes an extraneous trail‐ ing semicolon from the parameter lists of MIME header field values. The second replaces RFC 2047 encoding with RFC 2231 encoding of name and filename parameters in Content-Type and Con‐ tent-Disposition header field values, respectively. The -verbose switch directs mhfixmsg to output informational message for each transformation applied. The return status of mhfixmsg is 0 if all of the requested transformations are performed, or non-zero otherwise. (mhfixmsg will not decode to binary content with the default -decodetext setting, but a request to do so is not considered a failure, and is noted with -verbose.) If a problem is detected with any one of multiple messages such that the return status is non- zero, then none of the messages will be modified. The -file file switch directs mhfixmsg to use the specified file as the source message, rather than a message from a folder. Only one file argument may be provided. The -file switch is implied if file is an absolute pathname. If the file is “-”, then mhfixmsg accepts the source message on the standard input stream. If the -outfile switch is not enabled when using the standard input stream, mhfixmsg will not produce a transformed output message. mhfixmsg, by default, transforms the message in place. If the -outfile switch is enabled, then mhfixmsg does not modify the input message or file, but instead places its output in the specified file. An outfile name of “-” specifies the standard output stream. Combined with the -verbose switch, the -outfile switch can be used to show what transforma‐ tions mhfixmsg would apply without actually applying them, e.g., mhfixmsg -outfile /dev/null -verbose As always, this usage obeys any mhfixmsg switches in the user's profile."
        },
        {
            "flag": "",
            "long": null,
            "arg": null,
            "description": "folder, e.g., mhfixmsg -outfile - | \\ /usr/lib/mh/rcvstore +folder"
        }
    ],
    "examples": [
        "To run mhfixmsg on the current message in the current folder, with default transformations to",
        "fix MIME boundaries and Content-Transfer-Encoding, to decode text and application/ics content",
        "parts to 8 bit, and to add a corresponding text/plain part where lacking:",
        "mhfixmsg -verbose",
        "To run mhfixmsg on specified messages, without its informational output:",
        "mhfixmsg +inbox last:4",
        "By  default, mhfixmsg transforms the message in place.  To view the MIME structure that would",
        "result from running mhfixmsg on the current message, without modifying the message:",
        "mhfixmsg -outfile - | mhlist -file -",
        "To search the current message, which possibly contains base64  or  quoted  printable  encoded",
        "text parts, without modifying it, use the -outfile switch:",
        "mhfixmsg -outfile - | grep pattern",
        "tire message, not just text parts.",
        "To translate all text/plain parts in the current message to UTF-8, in addition to all of  the",
        "default transformations:",
        "mhfixmsg -textcharset utf-8",
        "To run mhfixmsg on all of the messages in a folder:",
        "mhfixmsg +folder all",
        "Alternatively,  mhfixmsg  can  be  run on each message separately, e.g., using a Bourne shell",
        "loop:",
        "for msg in `pick +folder`; do mhfixmsg +folder $msg; done",
        "The two appearances of the +folder switch in that command protect against concurrent  context",
        "changes by other nmh command invocations.",
        "To run mhfixmsg on messages as they are incorporated:",
        "inc  &&  mhfixmsg -nochangecur unseen",
        "This  assumes  that  the  Unseen-Sequence profile entry is set to unseen, as shown in mh-pro‐",
        "file(5)."
    ],
    "see_also": [
        {
            "name": "iconv",
            "section": "3",
            "url": "https://www.chedong.com/phpMan.php/man/iconv/3/json"
        },
        {
            "name": "inc",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/inc/1/json"
        },
        {
            "name": "mh-mkstemp",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/mh-mkstemp/1/json"
        },
        {
            "name": "mh-profile",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/mh-profile/5/json"
        },
        {
            "name": "mhbuild",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/mhbuild/1/json"
        },
        {
            "name": "mhlist",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/mhlist/1/json"
        },
        {
            "name": "mhparam",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/mhparam/1/json"
        },
        {
            "name": "mhshow",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/mhshow/1/json"
        },
        {
            "name": "procmail",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/procmail/1/json"
        },
        {
            "name": "procmailrc",
            "section": "5",
            "url": "https://www.chedong.com/phpMan.php/man/procmailrc/5/json"
        },
        {
            "name": "rcvstore",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/rcvstore/1/json"
        },
        {
            "name": "rmm",
            "section": "1",
            "url": "https://www.chedong.com/phpMan.php/man/rmm/1/json"
        }
    ]
}