Operating System - HP-UX
1751794 Members
4864 Online
108781 Solutions
New Discussion юеВ

How to e-mail a message in cc & bcc

 
SOLVED
Go to solution
praveen..
Super Advisor

How to e-mail a message in cc & bcc

Hi,
now i am using this to send a mail:

#cat file_name | mailx -s "Subject" praveen1@domain1.com,praveen2@domain2.com,praveen3@domain3.com

This sends the mail in "TO" filed.

but i need to send the same mail like:
To: praveen1@domain1.com
Cc: praveen2@domain2.com
bcc: praveen3@domain3.com

how to do that?

thankx
5 REPLIES 5
Steven E. Protter
Exalted Contributor
Solution

Re: How to e-mail a message in cc & bcc

Shalom,

mailx can be used for this.

I prefer sendmail because it is more flexible.

Take a look at http://www.hpux.ws/mailfile2

It has code for doing this with sendmail.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
praveen..
Super Advisor

Re: How to e-mail a message in cc & bcc

mailx cannt be used to send the mails on bcc?
Arturo Galbiati
Esteemed Contributor

Re: How to e-mail a message in cc & bcc

Hi Praveen,
I use mail which gives me teh possibility to add CC & BCC:

mail -t <Subject: test
From:
Cc:
bcc:

$(ux2dos file|uuencode file.log)
EOF

HTH,
Art
Cem Tugrul
Esteemed Contributor

Re: How to e-mail a message in cc & bcc

1. Mail No attachment, body only -

mailx -m -s "Some Subject" somone@somewhere.com < file_for_email_body

2. Mail with attachement, no body -

ux2dos /path_to/some_file | uuencode some_file.txt | mailx -m -s "MAIL FROM Someone" someone@somewhere.com

3. Mail with attachment and body -

ux2dos /path_to/some_file | uuencode some_file.txt | mailx -m -s "MAIL FROM Someone" someone@somewhere.com < file_for_email_body

4. Mail with carbon and blind carbon -

mailx -m -s "Some Subject" somone@somewhere.com < file_for_email_body

(Note that this does not work with the -r option as it disables ~ commands.)
(The file_for_email_body should look like this - )
~c someone_to_cc@somewhere.com
~b someone_to_bc@somewhere.com
The remainder of this file can be the text body of the email.

5. Mail with multiple attachments and body (Leave out the 'This is all you get' if body not desired) -

mailx -m -s "Hello" someone@somewhere.com << END
`ux2dos /home/dlamar/.kshrc | uuencode /home/dlamar/.kshrc.txt`
`ux2dos /home/dlamar/.profile | uuencode /home/dlamar/.profile.txt`
This is all you get.
END
Our greatest duty in this life is to help others. And please, if you can't
Cem Tugrul
Esteemed Contributor

Re: How to e-mail a message in cc & bcc

#!/usr/bin/sh

export EMAIL_TO=username@receiving.email
export EMAIL_FROM=username@sending.email
export EMAIL_SUBJECT="subject of e-mail"
export EMAIL_BODY=/tmp/body_of_e-mail
export FILE_NAME=filename.txt
export ATTACHED_FILE=/tmp/file_to_attach

{
echo To: $EMAIL_TO
echo From: $EMAIL_FROM
echo Subject: $EMAIL_SUBJECT
echo 'MIME-Version: 1.0'
echo 'Content-type: multipart/mixed; boundary="xxxxyyyzzqzzyyyxxxx"'
echo '--xxxxyyyzzqzzyyyxxxx'
echo ''
cat $EMAIL_BODY
echo '--xxxxyyyzzqzzyyyxxxx'
echo 'Content-Disposition: attachment; filename="'$FILE_NAME'"'
echo ''
cat $ATTACHED_FILE
echo '--xxxxyyyzzqzzyyyxxxx--'
} | /usr/sbin/sendmail $EMAIL_TO
Our greatest duty in this life is to help others. And please, if you can't