Send mail from the command line

BeOS does not include a full-blown command-line mail client (though you can download pine if you need it), but it does let you send off quick messages and text attachments if necessary. Try this:

mail -s "Howdy!"
[Enter message body here]

When done with your message, tap Ctrl-D. This sends an EOF (end of file) mark, which sends the message, using the settings established in the E-mail preferences panel. If you want to send an existing text file as the message body, use:

mail -s "Howdy!" < /path/to/file.txt

Note however that if you do this with a binary, rather than a text file, the binary will end up in the message body, not as an attachment.

Roman Filippov (rxf at alkor dot ru) adds:
The mail utility can also take two flags for setting CC: and BCC: addresses:




You can also list as many recepients as you wish on the command line. (e.g.: mail -s "Hello!" This is equivalent to entering multiple recepients in the To: field of a GUI mail client.
It’s also possible to send a binary file using mail, but it takes a bit more work, as you’ll need to convert the binary to text format with uuencode:

mail -s "Hello!" < uuencode  /path/to/

where remote_file stands for the file name which will be created by the decoder on the recipient computer, and /path/to/ is the path to the binary file you wish to send.
To decode the file on the recepient side type:

 uudecode < received_e-mail_file_name 

These commands, paired with attribute manipulation utilities and grep, can be used to build powerful script-based mail processing systems similar to those found in commercial mail clients.



No comments so far.

(comments are closed)