0

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
2

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).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.