Operating System - HP-UX
1819946 Members
3745 Online
109607 Solutions
New Discussion юеВ

batch eml sendmail: how to CC: ??

 
SOLVED
Go to solution
Vlad_11
Frequent Advisor

batch eml sendmail: how to CC: ??

Hi,
I"m using this line in my script:
elm -s "$SUBJECT" -a $MAILTO < body1

To send it to multiple guys I list @addresses thru the comma, but just curiose is there any way to say EML that any particular address should be CC: (or BC:). Couldn't find any info yet.
I need it to run in shell, not from command line.

THanks to all
Vittoiro
beer or not beer
13 REPLIES 13
Steven E. Protter
Exalted Contributor

Re: batch eml sendmail: how to CC: ??

Attaching a sendmail shell script. All you need to add is a cc: line or a bcc: line and you're done.

This script does attachments too.

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
Vlad_11
Frequent Advisor

Re: batch eml sendmail: how to CC: ??

Thanks, Steven !
I can't use this script, it's still interactive + I have some system limitation to stick with ELM.

Thanks
beer or not beer
Ken Penland_1
Trusted Contributor

Re: batch eml sendmail: how to CC: ??

well, I dont use elm on my HP, but doesnt the -c option work?

like:
elm -s "subject" -a user1 -c ccuser < file


I thought -c was for carbon copy, and -b was for bcc?
'
Ken Penland_1
Trusted Contributor

Re: batch eml sendmail: how to CC: ??

dang, disreguard the above, it looks like that is just a mailx thing or something...in searching the net the -c is for checking aliases.....I dont see any way to do it in batch mode :(
'
Jeff Schussele
Honored Contributor
Solution

Re: batch eml sendmail: how to CC: ??

Hi Vlad,

This is not easy non-interactive in either elm or mailx.
The only way I think you can do this in mailx is to embed at the beginning of the input file to the mailx command a

~c ccaddress@abc.com

~b bccaddress@abc.com would be a blind carbon copy.

HTH,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Dave La Mar
Honored Contributor

Re: batch eml sendmail: how to CC: ??

Vittoiro -
Our shop uses mailx extensively. Attached are some samples, one of which should help you out.

Best of luck.

Regards,

dl
"I'm not dumb. I just have a command of thoroughly useless information."
Rupesh_1
Occasional Advisor

Re: batch eml sendmail: how to CC: ??

HI All,
Dave's answer is perfect as we too use the same syntax in our scripts


Cheers
Rups
Vlad_11
Frequent Advisor

Re: batch eml sendmail: how to CC: ??

Thanks, Dave La Mar
couldn't make work with attachment yet, thought followed all you samples.

Is there any option to specify FROM@MAIL.COM address with mailx ?

Thanks
Vlad
beer or not beer
Dave La Mar
Honored Contributor

Re: batch eml sendmail: how to CC: ??

Vittoiro -
Both -
Mail with attachement, no body -

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

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

- are used extensively in our shop with no problems.
May I see the syntax of what you are attempting.
Have not investigated changing the from name; it defaults to the user executing the mailx and I would think it a security issue to allow change of this.

Best regards,

dl
"I'm not dumb. I just have a command of thoroughly useless information."
Vlad_11
Frequent Advisor

Re: batch eml sendmail: how to CC: ??

#ux2dos attach | uuencode attach.txt | mailx -m -s "$SUBJECT" $MAILTO < $BODY


cat attach|mailx -m -s "$SUBJECT" $MAILTO < $BODY

Both work fine but can't attach .

Thanks
beer or not beer
Dave La Mar
Honored Contributor

Re: batch eml sendmail: how to CC: ??

Your second example is not in the syntax for an attachment.
The first one:
1. Insure you specifiy full path to "attach" (and of course, that it exists).
2. Insure there are values assigned to "$SUBJECT" $MAILTO and $BODY.

i.e. ux2dos /home/vittoiro/.profile | uuencode profile.txt | mailx -m -s "Here is My Profile"
someone@somewhere.com < /some_path_to/Some_file_containing_your_lines_for_the_body_of_the_email

Sorry, if I am over simplifing.

Hang in there.

dl
"I'm not dumb. I just have a command of thoroughly useless information."
Vlad_11
Frequent Advisor

Re: batch eml sendmail: how to CC: ??

Hi, Dave !!!
Thanks for you posts. It's too simple to believe that I still don't have attachment going thru.
I played extensevely with /full/path.
$MAIL $BODY are well defined, I can see them in recieved email.
Is there any .config file, like in sendmail ?
or ??

So far I switched to ELM that works fine.

Thanks
Vlad
beer or not beer
Dave La Mar
Honored Contributor

Re: batch eml sendmail: how to CC: ??

Vittoiro -
Try this sample:
ux2dos /home/vittoiro/.profile | uuencode profile.txt | mailx -m -s "Here is My Profile"
vittoiro@your_email_address.com < /home/vittoiro/.profile

That should send your .profile both as an attachment and in the body of the email.
(vittoiro@your_email_address.com needs to be your valid email address)

Also note, I stand corrected on changing the from email address.
While I do not like this from a security standpoint, the email can look as though it came from someone else by using the -r option.
i.e. -r pope_paul@vatican.com

Best regards,

dl



"I'm not dumb. I just have a command of thoroughly useless information."