Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a saved mail (in Maildir format) including all headers and attachments.

I would like to send this file as email (with all the given headers intact) to a new email address, something like:

$ cat mail.txt  | forwardMail test@example.com

which should basically connect to the MTA, use test@example.com as the "RCPT TO" and the contents of mail.txt as the DATA.

I tried things like the following, but it doesn't handle headers and attachments gracefully; also, I have to specify the subject on the cmdline (while it is already defined in mail.txt).

 $ cat mail.txt | mail -s "foo" test@example.com
share|improve this question
up vote 2 down vote accepted

Pipe the message into /usr/lib/sendmail -i. (Some systems put it in /usr/sbin/sendmail instead.)

All MTAs (Postfix, Sendmail MTA, Exim, &c.) install their own version of the sendmail program, and it is the same tool that Mail and other Unix programs use to submit mail messages.

  • The recipient addresses are specified in the command line. (If you add -t instead, sendmail takes the recipients from the message's headers such as To:, which you do not want this time, but it might be useful in other cases.)

  • The -i option tells sendmail to disable the special treatment of lines starting with a dot; it is needed for historical reasons.

  • The -f $address option can be used to change the "envelope FROM" address (not related to the From: header).

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .