Postfix does not add to: header for outgoing mail
You don't need any To:
header for messages to be delivered to their destination. Only the SMTP envelope is used for that.
Unlike the mailx
tool the bare sendmail
command is not a full mail client.
The sendmail command will not create a properly formatted mail message, just the bare minimum SMTP envelope to ensure successful transmission. If you want a properly formatted email message, that's what you need to provide to the sendmail command as (standard) input.
In other words:
You need to supply sendmail with message consisting of headers, each header on a new line with a colon separating the header from the header value, with long headers continuing on the line below and starting with one or more spaces. Then an empty line separating the message headers from the body. Then the message body.
Something like this
To: [email protected]
Content-Type: text/plain; charset=us-ascii>
From: [email protected] (Hermanb)
Subject: A very very long
subject header spanning multiple lines
Date: Tue, 12 Jan 20121 15:46:24 +0200
test test
More test text
.