TurnKey Linux Virtual Appliance Library

How to send mail from command line (bash script)?

Markus KARG's picture

I want cron to send me an email every day by SMTP, so I tried to use the "mail -s" command (postfix is installed and working, as this is the TKL bugzilla appliance). But the command is not found. What is the "TKL way" to send a email from the command line (bash script)?

And, is there a way to tell cron that errors shall not go to /var/mail/root but actually are forwarded to an external address using SMTP?

Jeremy's picture

Sorry never used it myself...

If you keep in mind that TKL is based on Ubuntu 10.04/Lucid (most parts are binary identical, just with added software not from repos and some additional tweaking and preconfig etc) that should get you going. The Ubuntu Server Guide can be pretty handy. To be honest though I had a quick look and dspite the fact that I fond lots of info about install and config, I found basically none on stand alone usage...

So I had a quick search of the Ubuntu forums and still got nowhere... Even a general google didn't give me any clarity... some stuff said to use "mail" and some other stuff said to use "sendmail" but I wasn't completely sure I was getting the full picture...

Sorry I couldn't help more. Be great to hear back when you work it out as no doubt others will run up against this in the future...

Post new comment

The content of this field is kept private and will not be shown publicly. If you have a Gravatar account, used to display your avatar.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <p> <span> <div> <h1> <h2> <h3> <h4> <h5> <h6> <img> <map> <area> <hr> <br> <br /> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <em> <b> <u> <i> <strong> <font> <del> <ins> <sub> <sup> <quote> <blockquote> <pre> <address> <code> <cite> <strike> <caption>

More information about formatting options

Leave this field empty. It's part of a security mechanism.
(Dear spammers: moderators are notified of all new posts. Spam is deleted immediately)