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 Davis's picture

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...

Roland Blochberger's picture

I am using the 'LAMP Stack - Web Stack (MySQL) provided by TurnKey Linux' Version: 13.1*, released 04/24/2015 on Amazon EC2.

Although the server can send emails from PHP it has no working 'mail' command for a simple bash script I would like to run regularly from cron.

Now I have installed the 'mailutils' package and the 'mail' command is available but still it does not send emails to the outside world.

What do I need configure to make that work?

Jeremy Davis's picture

So TBH I'm not sure what that would need to work... IIRC the LAMP appliance uses Postfix as it's MTA and has sendmail installed too.

So something like thi; first create a test message:

cat > message.txt <<EOF
Subject: Email test

line 1
line 2

Send it:

sendmail < message.txt
Also BTW this thread is really old and relates to a previous TurnKey version that was based on Ubuntu. v13.x is based on Debian Wheezy...
Roland Blochberger's picture

Thank you for your suggestion, however, sendmail does not send to the outside world either.

Then I tried to call the PHP mail function in a PHP commmandline script. Does not work either :-(

I am pretty sure there is just some configuration missing, but I am not so deep into postfix to know it.


EDIT: the sendmail DID work, it just took ages for the email to show up at the recaiver mailbox.

Thank you very much

Jeremy Davis's picture

Just because you didn't get it, didn't mean it didn't send! ;)

Re why it took ages, that is a different matter. The headers of the email that you received may have some hints. Also might be worth chekcing the logs...

Add new comment