如何在UNIX邮件中使用CC和BCC?

时间:2013-09-08 16:47:28

标签: shell email unix

我有以下功能使用邮件。 如何在其中添加cc或bcc? 这样做不起作用:cat<< EOF |邮件$ {CONTACT_EMAIL} -b email@email.com.br ...

function SendMail () {
        # Getting e-mails body text
        TEXT=$(cat ${LOG_DIR}/${PROCESS_ID}.log)

cat << EOF | mail ${CONTACT_EMAIL}
From: ${MAIL_FROM}
Subject: X
To: X}
Cc: Leandro.Takeda@teste.com
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="-q1w2e3r4t5"
---q1w2e3r4t5
Content-Type: text/html
Content-Disposition: inline

X

EOF

}

2 个答案:

答案 0 :(得分:1)

man mail我的补偿建议-b a,b,c应该先发送到地址。

mail -b email@email.com.br ${CONTACT_EMAIL}

答案 1 :(得分:1)

您可以在没有sendmail计划帮助的情况下直接使用mail程序。

SENDMAIL=/usr/sbin/sendmail

${SENDMAIL} -i -- ${CONTACT_EMAIL} Leandro.Takeda@teste.com jd@example.net <<EOF
From: ${MAIL_FROM}
Subject: X
To: ${CONTACT_EMAIL}
Cc: Leandro.Takeda@teste.com
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="-q1w2e3r4t5"

---q1w2e3r4t5
Content-Type: text/html
Content-Disposition: inline

X

EOF