Koozali.org: home of the SME Server

Legacy Forums => General Discussion (Legacy) => Topic started by: osiris9510 on December 16, 2005, 08:04:28 PM

Title: e-mail via command line
Post by: osiris9510 on December 16, 2005, 08:04:28 PM
Is there a way to send e-mail using the command line/bash script?? Id like to e-mail server logs to myself when Im away from the server.
Title: Re: e-mail via command line
Post by: mapangojoe on December 16, 2005, 10:07:40 PM
Quote from: "osiris9510"
Is there a way to send e-mail using the command line/bash script?? Id like to e-mail server logs to myself when Im away from the server.



Usage: mail [-iInv] [-s subject] [-c cc-addr] [-b bcc-addr] to-addr ...
            [- sendmail-options ...]
       mail [-iInNv] -f [name]
       mail [-iInNv] [-u user]

You can also type "info mail" or "man mail" for more info.

  I hope the above info helps!

Chris Curtis
Title: e-mail via command line
Post by: osiris9510 on December 17, 2005, 12:03:47 AM
can you give me an example to send a short message?
Title: e-mail via command line
Post by: aaron on December 17, 2005, 02:14:16 AM
I've used:

Code: [Select]
mail -s"Server $HOSTNAME booting" monitor@blah.com admin < /tmp/msg.tmp

to send an email to "monitor" and "admin" where the email body is the contents of the file msg.tmp.

Interactively you can do a:
Code: [Select]
mail -sSUBJECT who@there.org <ENTER>
then type any message content then when done type a single .<ENTER> on an empty line (I thin kit asks for a CC address) then off goes the email.

Check out "mutt" rather than "mail" if you wish to send an attachment.