Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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:

post-commit:

#!/bin/sh
REPOS="$1"
REV="$2"
SENDTO="address1@domain.com, address2@domain.com"

# 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
SENDFROM=svn@audioaffair.co.uk

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"

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

1 Answer 1

up vote 2 down vote accepted

Get rid of the space after the comma:

SENDTO="address1@domain.com,address2@domain.com"

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

TMPFILE="/var/tmp/email_test"
EMAIL_SUB = "Subject: Your subject";
EMAIL_TO = "To: address1@domain.com, address2@domain.com";
EMAIL_BCC = "Bcc: address3@domain.com";
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 ping.co.il/node/2 –  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

 
discard

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.