我正在尝试在我的 shell 脚本中使用 mailx 向用户发送邮件,而不公开电子邮件地址。
这是我的一段代码 -
query1=$(sqlplus -s ${ORA_UID_PSWD} << 'EOF'
set heading OFF
SELECT cu.cntct_email
FROM cm_user cu, cm_usertype ct
WHERE trunc(cu.xprtn_dt) = trunc(sysdate) - 60
AND cu.cm_user_id=ct.cm_user_id
AND ct.user_type = 'E'
AND cu.cntct_email is not null;
EOF
)
user_list1=$(echo "$query1" | tr '\n' ',' | sed 's:^.\(.*\).$:\1:')
echo $user_list1
echo -e "Hi,\nFYI.. Your password is expired 60 days ago. Please login and get it reset.\n\nThanks" |mailx -s "Password expired" -b $user_list1
我尝试使用-b
选项(密件抄送),但出现错误 -
未指定主要收件人的发送选项。
用法:
mailx -eiIUdEFntBDNHRV~ -T FILE -u USER -h hops -r address -s SUBJECT -a FILE -q FILE
-f FILE -A ACCOUNT -b USERS -c USERS -S OPTION users
任何人都知道如何在不使用 To(Primary receepnt) 的情况下发送
如果mailx
没有做你想做的,你可以直接与sendmail
.
# Speculative; see below
PATH=/usr/libexec:$PATH
query1=$(sqlplus -s "$ORA_UID_PSWD" << 'EOF'
set heading OFF
SELECT cu.cntct_email
FROM cm_user cu, cm_usertype ct
WHERE trunc(cu.xprtn_dt) = trunc(sysdate) - 60
AND cu.cm_user_id=ct.cm_user_id
AND ct.user_type = 'E'
AND cu.cntct_email is not null;
EOF
)
# no need for further normalization of $query1 actually
sendmail -oi $query1 <<'EOF'
Subject: Password expired
To: undisclosed-recipients:;
Hi,
FYI... Your password has expired 60 days ago.
Please login and get it reset.
Thanks
EOF
如果sendmail
不在你的PATH
,可能更新你的PATH
(也许只是在这个脚本中)所以它是。常见的位置包括/usr/sbin
,/usr/libexec
等; 但如果这些没有帮助,请查阅您平台的文档以获得更好的猜测。
不需要显式Bcc:
标头;当您在命令行上指定收件人时,Sendmail 实际上会忽略标头。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句