How can I format a file so I can just do cat file | sendmail
?
By putting Subject: This is the subject
, I don't need to specify the subject in sendmail, but adding the To: [email protected]
field gives me Recipient names must be specified
How can I format a file so I can just do cat file | sendmail
?
By putting Subject: This is the subject
, I don't need to specify the subject in sendmail, but adding the To: [email protected]
field gives me Recipient names must be specified
You are missing the distinction between message contents (headers and body) and message envelope. You're invoking sendmail
with message contents, but you aren't supplying the envelope. It's the envelope that controls delivery. Without it, the message cannot go anywhere.
You don't say which sendmail
command that you are using. Each MTS — Sendmail, qmail, Postfix, exim, and so forth — has its own. The common subset of them all has just two ways of specifying envelope sender and envelope recipients:
sendmail
:< file sendmail -f [email protected] postmaster@localhost
To:
, Cc:
, and Bcc:
headers:< file sendmail -f [email protected] -t
This common subset is very limited. Observe, for example, that this mode of message submission from standard input and command arguments is Sendmail's -bm
mode, but not all sendmail
programs actually even support a -bm
option. So to portably invoke this mode, you cannot use the option.
There are also portability caveats when combining -t
with recipients given as command arguments, for the details of which see Dave Sill's book. So pick one form or the other. Don't mix them.
sendmail
injection". The qmail Handbook. ISBN 9781893115408. Apress. pp. 123–126.sendmail
. Postfix manual pages.sendmail
. Courier manual pages.cat
Award.By default, sendmail
expects the recipients to be specified on command line. Use -t
to make it read the To:
, Cc:
, Bcc:
headers.