Koozali.org: home of the SME Server

e-mail via command line

osiris9510

e-mail via command line
« 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.

mapangojoe

Re: e-mail via command line
« Reply #1 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

osiris9510

e-mail via command line
« Reply #2 on: December 17, 2005, 12:03:47 AM »
can you give me an example to send a short message?

aaron

e-mail via command line
« Reply #3 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.