Redistribution using your MTA

Great Email Features (You've Never Heard Of) - Supplemental Page

This month's Power Tools column shows ways to redstribute an email message (which is different than forwarding it).

Some email programs don't support redistribution. You can probably do it, anyway, by saving the original message in a file and passing it directly to your system's MTA. Here's a nuts-and-bolts approach using sendmail. (Other MTAs often have a front-end named sendmail which has the same command-line syntax.) Test it first by sending a message to an alternate mailbox of your own, or to someone who's sitting nearby.

  1. Get the original message into a file by itself. If your MUA stores mail in MH format (like Sylpheed, Mutt, and others do), you can use a file manager like Nautilus or a utility like cp to copy the file. Or use your MUA's "save" command to save the message.

    Be sure that the file is a legal message. (Message format is explained in the July, 2003 article Personal Post.) Especially, be sure that your email program leaves addresses in a legal format and that header continuation lines are indented.
  2. Find out how to invoke your MTA from a command line. In a terminal window, try typing which sendmail and see if you get an answer like /usr/bin/sendmail. If that doesn't find sendmail, try using ls -l to see whether the programs or /usr/lib/sendmail exist; if one does, you can run it by typing its absolute pathname.

    (If your MTA isn't sendmail, it may still have a front-end named sendmail that you can use as we'll show here.)

    If your computer isn't running an MTA, put the message on a host that does have an MTA. You may be able to do this from your local host with scp and ssh -- so you don't need to log into the remote host at all. The March, 2003 article "Transfer Tips, Part I" explains how; it's available online at http://www.linux-mag.com/2003-03/power_01.html.
  3. You can edit the message header to add "Resent-" fields. If you do, though, be sure they're in a legal format. (If they look like the To:, From: and Date: fields in messages that your MUA sends, they should be fine.) For example:
    Resent-From: jpeek@jpeek.com
    Resent-To: zoe@d.com, xp@foo.xyz
    Resent-Date: Wed, 21 July 2004 10:00:00 -0700
    
  4. Give the recipients' addresses (here, zoe@d.com and xp@foo.xyz) as arguments to sendmail. Separate them by spaces, not commas (,). Pass the message to sendmail's standard input; an easy way to do that is with the shell's operator <, which redirects a program's standard input from a file.

    For instance, if the message is in a file named msg, you could run:
    $ sendmail zoe@d.com xp@foo.xyz < msg
    
    You may also need to set the envelope sender address (the SMTP MAIL FROM address) to a legal address where bounces will be sent. You can do that with the sendmail -f address option. For instance, to set the envelope recipient to bounces@abc.xyz:
    $ sendmail -f bounces@abc.xyz zoe@d.com \
        xp@foo.xyz < msg
    
    If you do this often, try writing a little script that accepts addresses as command-line arguments and handles the other details. (Or switch to a more capable email program.)

[Return to Great Email Features (You've Never Heard Of) - Supplemental Page]

[Read previous article] [Read next article]
[Read Jerry’s other Linux Magazine articles]