我试图在SVN上设置一个post-commit钩子来使用bash脚本向一群用户发送邮件。 我已经成功地设置了钩子,并且只有一个邮件地址被指定时才起作用。 但是,当更多的电子邮件地址添加没有邮件到达。 bash脚本如下:
提交后:
#!/bin/sh REPOS="$1" REV="$2" SENDTO="[email protected], [email protected]" # Send it to these people, calling the script we created above /home/www/svn/bin/svn_email_commit.sh "$REPOS" "$REV" "$SENDTO"
svn_email_commit.sh:
#!/bin/bash REPOS=$1 REV=$2 SENDTO=$3 [email protected] LIMITDIFF=200 # Do various other stuff and dump mail body to a temp file $TMPFILE... # Send email /bin/cat $TMPFILE | /bin/mail -s "$SUBJECT" "$SENDTO"
问题在于/ bin / cat $ TMPFILE | / bin / mail -s“$ SUBJECT”“$ SENDTO”如果有多个$ SENDTO地址,则不起作用。 它只有一个地址时才起作用。
我在CentOS 5.7上
摆脱逗号后的空格:
SENDTO="[email protected],[email protected]"
如果这不起作用,只需使用sendmail。 像这样的东西:
TMPFILE="/var/tmp/email_test" EMAIL_SUB = "Subject: Your subject"; EMAIL_TO = "To: [email protected], [email protected]"; EMAIL_BCC = "Bcc: [email protected]"; echo "$EMAIL_TO" >> ${TMPFILE} echo "$EMAIL_SUB" >> ${TMPFILE} echo "$EMAIL_BCC" >> ${TMPFILE} /usr/lib/sendmail -t < ${TMPFILE}