ssmtp is just one of many Sendmail wrappers. All of these accept a message on standard input, and optionally a list of addresses as command-line arguments, and they all offer a binary named
sendmail which implements (at least the basic features of) the traditional Sendmail command-line API. But properly speaking, that message needs to be well-formed RFC822 message. At minimum, it should have a
ssmtp [email protected] <<<$'Subject: testing 1...2...3'
sendmail is just a symlink to
ssmtp. Postfix, Exim, and I believe every other MTA which
Provides: mail-transport-agent has a similar arrangement, except of course
sendmail where the
sendmail binary is "the real thing".)
More commonly, you can piece together a simple email message with a here document.
/usr/lib/sendmail -oi -t <<____HERE
To: [email protected]
Here we interpolate the shell variable $result
-t option says to take the recipient list from the headers of the message you receive on standard input. The precise path to Sendmail will differ between platforms.)
Another common variation is to combine the output of a few commands. Take care to have an empty line (a "neck") between the headers and the message body.
( printf "Subject: random number\n\n"
dd if=/dev/urandom bs=4 count=1 2>/dev/null | od -D -An ) |
sendmail [email protected]
For anything beyond very simple ASCII text-only messages, you need to understand how to compose a proper MIME message, at which point it usually makes more sense to use a tool like
mutt. Some platforms have a
mailx which knows how to send attachments and non-ASCII text, but this is not fully portable.
The challenge here is not finding a client which can take an email message and attempt to send it, it is to configure it for the specifics of Gmail, which requires the MTA to know the user name and password to use for the remote server in order to be able to use it as the outgoing smarthost.
Behind the scenes, most clients like
mailx, etc typically just run
sendmail behind the scenes to get the message off the system.