0

I have postfix running in a Docker container. A cronjob try to send email, but reply

“(CRON) info (No MTA installed, discarding output)” error in the syslog

According to this link, the solution is to install postfix so CRON can send email.

I have postfix running on this Host, is there a way to use it ? I have some other hosts and postfix isn't running on them, can I also tell them to use the distant docker mail server?

  • Without seeing the crontab, we can't guess which problem you ran into. – Thomas Dickey Jul 28 '16 at 8:27
  • Maybe I'm misreading this, but what I see is that a process tried to send mail and it failed. I don't understand why the details of the command whose output got piped into mail would be important. – G-Man Jul 29 '16 at 1:51
  • @ThomasDickey & G-Man : please read this serverfault.com/questions/449651/… & askubuntu.com/questions/222512/… , the crontab is not relevant here. – Dimitri Kopriwa Jul 29 '16 at 6:52
2

The problem is not that postfix is not running but that it should be listening on a mapped port 25 or 587 on the host. Even if that is the case, with not installing postfix on the host, there is probably no installed that sends the mail (gotten from stdin or commandline parameters) to the port.

You install the client programs sSMTP or msmtp for that, but I have solved this within a small wrapper program for my crontab entries that I was using anyway. The wrapper only sends mail if the program (the "real" crontab etnry it called) exits with non-zero exit value or its output contains the string "error:". That reduces the span from my own systems i.e. no email if the program ran fine. The program uses the Python standard library smtp module to send the caught output.

The wrapper runs the program with subprocess.check_output(cmd, stderr=subprocess.STDOUT), and sends the result on error using:

 smtp = smtplib.SMTP(host="", port=0)  # by default 'localhost' and 25
 smtp.connect()
 smtp.sendmail(
     from_email, to_email_list,
     email_header_and_body
 )

By setting the host and port I also use this to run jobs from other docker containers.

  • Not sure if I got it, why should I use a hook script ? Is there no way to configure an external SMTP server ? – Dimitri Kopriwa Jul 30 '16 at 5:51
  • I'm not sure what a "hook" script is. There is no way to configure "vixie" cron (found on most Linuxes nowadays) to use a specific server/port. – Anthon Jul 30 '16 at 5:58
  • solution seems to just install ssmtp or msmtp – Dimitri Kopriwa Jul 30 '16 at 8:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.