воскресенье, 10 января 2010 г.

Task: send email notification after SVN commit

This is supposed to be in svn post-commit hook file:

#get username of the user making commit
user=$(/usr/local/bin/svnlook author -r $REV $REPOS)

#send email message to admin
/usr/local/bin/php mail.php "from@email" "$user/$1" "to@email" "$log"

Code for mail.php is here:

<?php

//script usage php mail.php <fromemail> <subject> <toemail> <text>

if ($argc<5) die ("script usage php mail.php <fromemail> <subject> <toemail> <text>");
$frommail=$argv[1];
$subj=$argv[2];
$tomail=$argv[3];
$text=$argv[4];
$rez=mail($tomail, "$subj", $text,
"From: $frommail\nReply-To: $frommail");
if (!$rez) die ("error sending mail to $tomail");
?>

Комментариев нет: