3 ms·
Cron already supports sending email for jobs (or at least the cron's on Unix/Linux machines do so). Just don't redirect the output anywhere and cron emails it
by pwg 12y ago
Cron already supports sending email for jobs (or at least the cron's on Unix/Linux machines do so). Just don't redirect the output anywhere and cron emails it to the owner of the cron job. Assuming that MacOS's cron is not too far modified, all you need is a replacement "sendmail" command, in the location that MacOS cron would look for it, that submits cron's output to an SMTP server for delivery.
Given that MacOS already ships with Tcl/Tk, if you install TclLib (http://wiki.tcl.tk/1246 http://wiki.tcl.tk/1246) such that the native Tcl/Tk can find it (note, I have no Mac, so I have no knowledge of 'how' to install TclLib on MacOS) then you need a four line Tcl script to create a replacement "sendmail" command:
#!/usr/bin/tclsh
package require mime
package require smtp
set mesg [::mime::initialize -string [read stdin]]
::smtp::sendmessage $mesg -servers smtp.server.name.com \
-client this.machines.name.com \
-originator email@address.to.use.as.from.com \
-recipients destination@email.address.com
Replace 'smtp.server.name.com', 'this.machines.name.com', 'email@address.to.use.as.from.com', and 'destination@email.address.com' with the appropriate items for your environment and you (on Linux, at least) will be good to go. Hopefully MacOS's cron is not too far afield from standard Unix cron.
- graffitici 12y agoThanks for the answer. I'll look into Mac OS X cron's ability to send output. But my main answer was in finding an SMTP service that can send emails. In your example, don't you have to log in to smtp.server.name? If so, don't you need to put a password somewhere in that tcl script?
- pwg 12y agoYes, but as I own my domain name and run my own email, the smtp server I use is mine. You could try looking up google's SMTP server and try it to see if it would work (it should): nslookup -q=mx google.com ... google.com mail exchanger = 10 aspmx.l.google.com. google.com mail exchanger = 20 alt1.aspmx.l.google.com. google.com mail exchanger = 30 alt2.aspmx.l.google.com. google.com mail exchanger = 40 alt3.aspmx.l.google.com. google.com mail exchanger = 50 alt4.aspmx.l.google.com.