Email

將郵件發送到多個地址不起作用

  • September 26, 2011

我正在嘗試在 SVN 上設置一個送出後掛鉤,以使用 bash 腳本向一群使用者發送郵件。我已經成功設置了鉤子,並且只指定了一個電子郵件地址時它可以工作。但是,當添加更多電子郵件地址時,沒有郵件到達。bash 腳本如下:

送出後:

#!/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"

問題是 /bin/cat $ TMPFILE | /bin/mail -s " $ 學科” ” $ SENDTO" does not work if there are multiple $ 發送地址。它在只有一個地址時有效。

我在 CentOS 5.7

去掉逗號後的空格:

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

如果這不起作用,請嘗試使用 sendmail。像這樣的東西:

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}

引用自:https://serverfault.com/questions/315386