Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

1 Answer

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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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