Here's how to send email with full control over who it is from, who gets a copy, who it goes to, and what the body of the message is.
The key is to use mutt, a mail client that is already installed on many Linux systems. There are two steps to using it so that your email is sent as desired:
Here's an example:
export EMAIL="Dan Coutu <email@example.com>"
This will send 'myfile' to Joanie and me, from me, even if I'm logged in as some other user (such as apache because this is running as from a CGI).
As you see I'm redirecting stdin from a file and this implies that you can just feed the message you wish to send into mutt's stdin and away it will go.
Copyright © 2002-2011, Snowy Owl Consulting, LLC"));