-- Retrospect Event Handler for Mail.app for OSX -- •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• -- You _must_ edit these email address property definitions. Insert the desired recipients -- into each group using quote marks, commas to separate multiple recipients, or -- leave curly brackets empty to not receive any mail for a group. Addresses must be -- in the form of one of the examples below, and a mix of the two types can be used. -- •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• property kMainGroup : {"dan@yourmailserver.com", "john@yourmailserver.com"} --will get mail for all events . property kMailServer : "127.0.0.1" -- the smtp server to use for sending mail property kFrom : "admin@yourmailserver.com" -- the from address for the mails that Retrospect sends --SMTP Authentication --if your mail server uses SMTP authentication, enter the username and password here property kUsername : "" property kPassword : "" -- the full path to the script that sends mail property kScriptCommand : "/usr/bin/python /Library/Preferences/Retrospect/macmail.py" property kTimeHours : 13 property kRetrospectReport : ":Applications:Retrospect 6.1:Backup Report" -- Nothing below this line needs to be edited. -- -- End of properties for the sendMail Function. -- -- Properties needed for the mediaRequestTimedOut function. -- always intialize globals tell application "Finder" set RetrospectReport to ((name of startup disk) & kRetrospectReport) update file RetrospectReport set tRetrospectReport to modification date of file RetrospectReport set tCurrent to (current date) set tDiff to (tCurrent - tRetrospectReport) end tell -- -- start of the Retrospect suite if (tDiff > (3600 * kTimeHours)) then set theMessage to "Last Backup Date : " & tRetrospectReport & ". It has been more than " & kTimeHours & " hours since the last successful backup." set mySubject to "Retrospect Backup ALERT!!" sendMail given Subject:mySubject, myMessage:theMessage, recipientsList:kMainGroup else set theMessage to "Last Backup Date : " & tRetrospectReport & ". It has been less than " & kTimeHours & " hours since the last successful backup." set mySubject to "Retrospect Backup OK!" sendMail given Subject:mySubject, myMessage:theMessage, recipientsList:kMainGroup end if -- sendmail function for shell driven mail sending to sendMail given Subject:subj, myMessage:bodyText, recipientsList:reciplist if reciplist is {} or reciplist is "" or reciplist is {""} or bodyText is "" then return -- Nothing or no one to send to. set reciplist to reciplist as list --Here we writet the message body to a temporary file, so that macmail.py doesn't have to deal with shell limitations (such as maximum number of characters on the command line set target_file to "tmp:macmail.message" --no poisoning of our emails by other users do shell script "/bin/rm -f " & POSIX path of target_file my write_to_file(bodyText, target_file, false) repeat with toaddress in reciplist do shell script kScriptCommand & space & toaddress & space & kMailServer & space & quoted form of subj & space & POSIX path of target_file & space & kFrom & space & kUsername & space & kPassword end repeat --ditch the temp file do shell script "/bin/rm -f " & POSIX path of target_file end sendMail -- idle handler for delayed sending in backup server scripts. -- From apple essential subroutines on write_to_file(this_data, target_file, append_data) try set the target_file to the target_file as text set the open_target_file to ¬ open for access file target_file with write permission if append_data is false then ¬ set eof of the open_target_file to 0 write this_data to the open_target_file starting at eof close access the open_target_file return true on error try close access file target_file end try return false end try end write_to_file