You should look at the manual pages for sendmail. I have only included the bare minimum to get you started. You can add headers like "To:", "Cc:", "Bcc:", "Apparently-To:", etc. This can be done manually or via the -O options, e.g. -O "NoRecipientAction=add-to"