LinuxCommandLibrary

mh_lint

Check mail messages for syntax errors

TLDR

Check the current directory

$ mh_lint
copy

Check a specific directory recursively
$ mh_lint [path/to/directory]
copy

Check a MATLAB file
$ mh_lint [path/to/file.m]
copy

Check an Octave file
$ mh_lint --octave [path/to/file.m]
copy

SYNOPSIS

mh_lint [options] [message...]

PARAMETERS

-help
    Display help information and exit.

-version
    Display version information and exit.

-file file
    Specify a file containing the message to lint. If not specified, mh_lint reads from standard input.

-nofix
    Do not attempt to fix any problems with the headers, just report them.

-check keyword
    Specify a specific check to perform. Multiple checks can be specified with multiple -check options. Common keywords include: date, addr, charset, etc.

-nocheck keyword
    Disable a specific check. This can be used to override default checks.

message
    The message(s) to check. If no message is specified and -file is not given, mh_lint will read from standard input.

DESCRIPTION

The mh_lint command is a utility within the MH (Mail Handler) suite designed to check message headers for adherence to various RFC (Request for Comments) specifications and common mail formatting conventions.

It analyzes message headers, flagging potential errors, inconsistencies, or stylistic issues that might cause problems with mail delivery, processing, or display. The linter typically checks for things like invalid date formats, malformed addresses, missing required headers, and adherence to character encoding standards.

By using mh_lint, users can improve the reliability and compatibility of their email messages, ensuring that they are correctly interpreted by different mail clients and servers. It helps maintain consistency in email formatting, which can be crucial for automated mail processing systems and general readability. The output often provides warnings and suggestions for correcting identified problems, aiding in the creation of well-formed email messages.

CAVEATS

The specific checks performed by mh_lint, and the extent to which it can fix problems, may vary depending on the implementation. Some issues may not be detectable or correctable automatically.

RETURN VALUE

mh_lint returns 0 on success (no errors found), and a non-zero value if errors are detected.

EXAMPLES

To lint a message from a file:
mh_lint -file message.txt

To lint a message piped from another command:
cat message.txt | mh_lint

To perform only the date check:
mh_lint -check date message.txt

SEE ALSO

sendmail(8), mail(1)

Copied to clipboard