我正在尝试在 SVN 上设置提交后钩子,以便使用 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"
问题是,如果有多个 $SENDTO 地址,/bin/cat $TMPFILE | /bin/mail -s "$SUBJECT" "$SENDTO" 不起作用。只有一个地址时,它可以工作。
我在 CentOS 5.7 上
答案1
删除逗号后的空格:
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}