[SWLUG] mail command

justin at discordia.org.uk justin at discordia.org.uk
Sun Jan 26 17:08:29 UTC 2003


On 26 Jan, bascule wrote:
> ok this is doing my head in,
> how do i get mail to not be interactive, i just want to have a one line 
> command run when i tell it to that sends an email to a local user, only the 
> mail command insists on waiting to be told who to cc to!

In a shell script

mail -s "Blah Subject Blah" -c "" joe.bloggs at nowhere.com <<EOF
Blah
Blah
some mail
blah
blah
EOF


Where <<EOF means read rest of this script as if it was an input file.
and can be just replaced with  '< somefile' instead.

The other way is to compose your email, With From: To: and Subject:
lines included, and call 'sendmail -t < file'




More information about the Swlug mailing list