3. 修改/etc/mail.rc 增加內容
set [email protected] smtp=smtp.126.com smtp-auth-user=xxx smtp-auth-password=123456 smtp-auth=login
4. 增加svn_email_commit.sh發送郵件腳本,內容如下:
#!/bin/bash
REPOS=$1
REV=$2
SENDTO=$3
[email protected]
LIMITDIFF=200
CHANGELOG=`svnlook log -r $REV $REPOS`
AUTHOR=`svnlook author -r $REV $REPOS`
CHANGED=`svnlook changed -r $REV $REPOS`
DIFF=`svnlook diff -r $REV $REPOS | head --lines=$LIMITDIFF`
DATE=`date`
TMPFILE=/tmp/svn$REV-$RANDOM.message
SUBJECT="SVNCommit ($AUTHOR) $REPOS [$REV]"
echo "-------------------- SVN Commit Notification --------------------
Repository: $REPOS
Revision: $REV
Author: $AUTHOR
Date: $DATE
-----------------------------------------------------------------
Log Message:
-----------------------------------------------------------------
$CHANGELOG
-----------------------------------------------------------------
Changes:
-----------------------------------------------------------------
$CHANGED
-----------------------------------------------------------------
Diff: (only first $LIMITDIFF lines shown)
-----------------------------------------------------------------
$DIFF
" > $TMPFILE
# Send email
#cat $TMPFILE | mail -a "From: $SENDFROM" -s "$SUBJECT" "$SENDTO"
cat $TMPFILE | mail -a "$TMPFILE" -s "$SUBJECT" "$SENDTO"
# Cleanup
rm $TMPFILE
5. 修改post-commit腳本
#!/bin/sh
export LC_CTYPE=zh_CN.UTF-8
export PATH=$PATH:/usr/local/svn/bin:/opt/svnrepo/upublish/hooks:
REPOS="$1"
REV="$2"
SENDTO="[email protected]"
# Send it to these people, calling the script we created above
/opt/svnrepo/upublish/hooks/svn_email_commit.sh "$REPOS" "$REV" "$SENDTO"
6. 自動sendmail服務
7. 可以測試
mail -s "test" [email protected]