An MH Primer
Prev |  |

# 4 Sending Mail

Email is a two way street for most people so you want to be able to send something back. The way MH handles sending mail can be a bit difficult to follow at first, but it allows for incredible flexibility. The first thing MH does is to copy a components file into your outgoing email. A components file is basically a skeleton email letter with stuff like the `To:` and `Subject:` headers already in it. You are then sent into your editor where you fill in the header information and then type the body of your message below the dashed lines in the message. When you leave the editor, the `whatnow` program is run. When you are at the `What now?` prompt you can tell it to `send`, `list`, `edit`, `push`, and `quit`. Most of these commands are self-explanatory. So the message sending process involves copying a component file, editing your email, and then telling the `whatnow` program what to do with your email.

## 4.1 `comp`, `forw`, `reply`--compose, forward or reply to a message to someone

The `comp` program has a few useful command line options. The most important one to know right now is the `-editor` option. When MH is installed the default editor is usually a program called `prompter` which comes with MH. It is not a very exciting editor and basically just gets the job done. So when you go to compose a message to someone you might want to use `comp -editor /usr/bin/vi` or `comp -editor /usr/local/bin/pico` instead. Once you have run comp you are in your editor and you see something that looks like this:

    To:
    cc:
    Subject:
    --------

You need to put the person you are sending the mail to after the `To:` line. It works the same way for the other headers also, so you would need to put your subject after the `Subject:` line. Then you would just put the body of your message after the dashed lines. It may seem a bit simplistic since a lot of email programs have special requesters that ask you for this information but there really is no point to that. Plus this really gives you excellent flexibility.

    To:freebsd-rave@FreeBSD.org
    cc:
    Subject:And on the 8th day God created the FreeBSD core team
    --------
    Wow this is an amazing operating system. Thanks!

You can now save this message and exit your editor. You will see the `What now?` prompt and you can type in `send` or `s` and hit return. Then the FreeBSD core team will receive their just rewards. As I mentioned earlier, you can also use other commands at the `What now?` prompt. For example you can use `quit`, if you do not want to send the message.

The `forw` command is stunningly similar. The big difference being that the message you are forwarding is automatically included in the outgoing message. When you run `forw` it will forward your current message. You can always tell it to forward something else by doing something like `forw 23` and then message number 23 will be put in your outgoing message instead of the current message. Beyond those small differences `forw` functions exactly the same as `comp`. You go through the exact same message sending process.

The `repl` command will reply to the current message, unless you give it a different message to reply to. `repl` will do its best to go ahead and fill in some of the email headers already. So you will notice that the `To:` header already has the address of the recipient in there. Also the `Subject:` line will already be filled in. You then go about the normal message composition process and you are done. One useful command line option to know here is the `-cc` option. You can use `all`, `to`, `cc`, `me` after the `-cc` option to have `repl` automatically add the various addresses to the `Cc:` list in the message. You have probably noticed that the original message is not included. This is because most MH setups are configured to do this from the start.

## 4.2 `components`, and `replcomps`--components files for `comp` and `repl`

The `components` file is usually in `/usr/local/lib/mh`. You can copy that file into your MH Mail directory and edit to contain what you want it to contain. It is a fairly basic file. You have various email headers at the top, a dashed line and then nothing. The `comp` command just copies this `components` file and then edits it. You can add any kind of valid RFC822 header you want. For instance you could have something like this in your `components` file:

    To:
    Fcc: out
    Subject:
    X-Mailer: MH 6.8.3
    X-Home-Page: http://www.FreeBSD.org/
    -------

MH would then copy this components file and throw you into your editor. The `components` file is fairly simple. If you wanted to have a signature on those messages you would just put your signature in that `components` file.

The `replcomps` file is a bit more complex. The default `replcomps` looks like this:

    %(lit)%(formataddr %<{reply-to}%?{from}%?{sender}%?{return-path}%>)\
    %<(nonnull)%(void(width))%(putaddr To: )\n%>\
    %(lit)%(formataddr{to})%(formataddr{cc})%(formataddr(me))\
    %<(nonnull)%(void(width))%(putaddr cc: )\n%>\
    %<{fcc}Fcc: %{fcc}\n%>\
    %<{subject}Subject: Re: %{subject}\n%>\
    %<{date}In-reply-to: Your message of "\
    %<(nodate{date})%{date}%|%(pretty{date})%>."%<{message-id}
                 %{message-id}%>\n%>\
    --------

It is in the same basic format as the `components` file but it contains quite a few extra formatting codes. The `%(lit)` command makes room for the address. The `%(formataddr)` is a function that returns a proper email address. The next part is `%<` which means if and the `{reply-to}` means the reply-to field in the original message. So that might be translated this way:

    %<if {reply-to} the original message has a reply-to
    then give that to formataddr, %? else {from} take the
    from address, %? else {sender} take the sender address, %?
    else {return-path} take the return-path from the original
    message, %> endif.

As you can tell MH formatting can get rather involved. You can probably decipher what most of the other functions and variables mean. All of the information on writing these format strings is in the MH-Format manual page. The really nice thing is that once you have built your customized `replcomps` file you will not need to touch it again. No other email program really gives you the power and flexibility that MH gives you.

Prev | Home |
Folders and Mail Searching |  |