Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to setup a post-commit hook on SVN to send mail to a bunch of users using bash scripts. I have successfully setup the hook and it works when only one email address is specified. But when more email addresses are added no mail arrives. The bash scripts are as follows:



# Send it to these people, calling the script we created above
/home/www/svn/bin/ "$REPOS" "$REV" "$SENDTO"



# Do various other stuff and dump mail body to a temp file $TMPFILE...

# Send email
/bin/cat $TMPFILE | /bin/mail -s "$SUBJECT" "$SENDTO"

The problem is that /bin/cat $TMPFILE | /bin/mail -s "$SUBJECT" "$SENDTO" does not work if there are multiple $SENDTO addresses. It works when there is only one address.

I'm on CentOS 5.7

share|improve this question
First add an echo for the SENDTO in your second script and add a -v to your mail command to see what is actually happening. I just tested this out by exporting two email addresses to a variable and it seems to be working fine for me. – SparX Sep 26 '11 at 1:03
adding -v to mail gives no additional information – Ali Sep 26 '11 at 18:31
Thats weird..What about the echo in the second script? It will tell you whether your script reads the input properly. – SparX Sep 26 '11 at 18:37
up vote 3 down vote accepted

Get rid of the space after the comma:


If that doesn't work try just using sendmail. Something like this:

EMAIL_SUB = "Subject: Your subject";
EMAIL_TO = "To:,";
EMAIL_BCC = "Bcc:";
echo "$EMAIL_TO" >> ${TMPFILE}
echo "$EMAIL_SUB" >> ${TMPFILE}
echo "$EMAIL_BCC" >> ${TMPFILE}
/usr/lib/sendmail -t < ${TMPFILE}
share|improve this answer
getting rid of the comma has no effect. – Ali Sep 26 '11 at 18:30
I solved this using sendmail as ACase suggested, though ACase your script appears to be perl and not bash. Also got help from – Ali Sep 26 '11 at 18:33
Oops, cut and paste error. Cleaned it up. If your problem is solved you should mark it as answered. – Andrew Case Sep 26 '11 at 21:11

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.