[plug] send e-mail via command line

James Devenish devenish at guild.uwa.edu.au
Sat Aug 9 19:45:33 WST 2003

In message <sf35504f.067 at mmtnetworks.com.au>
on Sat, Aug 09, 2003 at 07:49:19PM +0800, Jon  Miller wrote:
> mail doesn't work either,

What was the error message for `mail`?

> the error was 
> gateway:~# echo "Virus updates completed" |/usr/sbin/sendmail -s "IDE updated" jlmiller at mmtnetworks.com.au
> sendmail: invalid option -- s
> sendmail: fatal: usage: sendmail [options]
> gateway:~#
> I can get it to work this way without the -s , but I thought the -s was for the subject line.

I think that must be a misconception about -s. I just had a look at a
few machines and none of them have include an -s option with Sendmail.
Only `mail` (and other mail clients, such as `mutt`) support -s for
setting the Subject header.

> The MTA is postfix on this system.

That is an essential detail.

> Also I'm trying to get it to include a from: parameter.

For e-mail, these are known as "headers" (i.e. From header, Subject
header, To header, etc.).

Have a look at `man sendmail` if you want to know about the Postfix
sendmail interface. Perhaps the -F option appeals.

Also, you could have a at look at `man mail` and see if the it supports
the "-a" option for specifying custom headers. If so, you could craft
your own "From: you at blah" header.

If you cannot find an tools that support the command-line options that
you want, you could just craft the entire mail message like this:

# (echo "To: John Miller <a at b.c>"; echo "From: Robot <d at e.f>"; echo "Subject: task completed"; echo; hostname) | sendmail -t

The above is a bit of an awkward-looking command but that is because I
am not making use of any shell tricks.

More information about the plug mailing list