Hi All,
Can we send a mail in unix blank in TO address with CC and BCC.
TO address should be blank
CC should not be blank
BCC should not be blank
thanks,
Hi All,
Can we send a mail in unix blank in TO address with CC and BCC.
TO address should be blank
CC should not be blank
BCC should not be blank
thanks,
Use sendmail, specify just CC & BCC:
{
print "CC: user@domain.com"
print "BCC: user@domain.com"
print "Subject: Testing CC & BCC"
print "Testing CC & BCC"
} | /usr/sbin/sendmail -t
I am using the below function and parameters
Here $c is TO address and $d is CC. But whenever ther is null in $c it is taking $d as in TO address.
My requirement is if there is null in $c then there should be no one in TO address and $d should be in CC.
notify_users_Weekly $UNEXPENSED_EMAIL_WEEKLY_SUBJ $BASE_UNEXPENSED_LIST_DIR_WEEKLY/User_Email_Msg_30.txt $c $d
Can you post what exactly you are doing inside this function?
function notify_users_Weekly
{
subject=$1
contents=$2
address=$3
CCaddress=$4
mailx -s """$subject""" """$address""" -c """$CCaddress"""< $contents >> RC=$?
return $RC
}
Please use code tags for posting code fragments or data samples.
I guess in mailx, primary recipient address is not an optional argument. You do have to specify it.
So why don't you use sendmail instead which can deliver email without a primary recipient?
Yoda is right. Try something more basic than mailx
.
Perhaps mail
is more basic.
But if your system has sendmail
, go for it!
More customized for your needs
echo "\
Subject: $subject
Cc: $CCaddress
$contents
" | sendmail $address
NB: there must be an empty line between mail header and mail body.
The sendmail program might hide in /usr/lib/
And if you want a To:
line, just add it to the mail header!
mailx
and perhaps mail
automatically place $address
(the envelope) in a To:
line,
i suppose since you are using command line arguments and assigning it to some other variables and when you do not give any one of the argument on command line the next argument becomes that argument
i.e example if you have to pass 4 arguments and if you specify only three then
i.e if suppose u pass 1st 2nd and 4th argument on command line then
the ath argument in above will become 3rd
so it would be better if you can introduce a check and let user know that if he doesny want to specify the to address can u ask then to enter a space in quotes
all pls correct me if im wrong