Thanks Michael. I am now using Mail::Sendmail and it
works as intended, though Im still curious how it's
done in the 'raw' :)
Thanks,
Christie
--- Michael Chaney <[EMAIL PROTECTED]> wrote:
> On Wed, Oct 31, 2001 at 05:34:13PM -0800, Mary
> Christie Generalao wrote:
> > hi gurus,
> > Just a little favor :) I am writing a perl script
> to
> > send some text to several recipients, some of
> which
> > must be CC'd (not in the To: header). How must a
> CC
> > header properly inserted? As an example, suppose I
> > send to [EMAIL PROTECTED] and Cc'd to [EMAIL PROTECTED] and [EMAIL PROTECTED]
> My
> > code is this:
> >
> > open(MAIL, "| /usr/sbin/sendmail a\@a.com");
> > open(TEXT, "mail.txt");
> > while (<TEXT>)
> > {
> > print MAIL "From: me\@sgp.a.com\n";
> > print MAIL "Cc: c\@c.com, b\@b.com\n";
> > print MAIL "Subject: test only\n\n";
> > print MAIL $_;
> > }
> > close(TEXT);
> > close(MAIL);
> >
> > With the above, [EMAIL PROTECTED] actually received the mail
> but
> > those in the CC didnt. Any hints please? I'd
> really
> > appreciate any comments.
>
> Use one of the many mail packages available at CPAN
> to send mail. I use
> Mail::Mailer, but Mail::Send is useful, too.
>
> It's my belief that the above program doesn't do
> what you want.
> Presumably, you want to send the contents of
> mail.txt to [EMAIL PROTECTED], but in
> fact your program repeats the from, cc, and subject
> lines for each line
> in the file.
>
> use Mail::Mailer;
>
> open(TEXT, "<mail.txt") or die "Can't open mail.txt:
> $!";
> @msgbody=<TEXT>;
> close TEXT;
>
> %headers= (
> 'To' => '[EMAIL PROTECTED]',
> 'From' => '[EMAIL PROTECTED]',
> 'Subject' => 'test only',
> 'CC' => '[EMAIL PROTECTED], [EMAIL PROTECTED]'
> );
>
> $mailprog=Mail::Mailer->new('sendmail');
>
> $mailprog->open(\%headers);
>
> print $mailprog @msgbody;
>
> $mailprog->close;
>
> Michael
> --
> Michael Darrin Chaney
> [EMAIL PROTECTED]
> http://www.michaelchaney.com/
> _
> Philippine Linux Users Group. Web site and archives
> at http://plug.linux.org.ph
> To leave: send "unsubscribe" in the body to
> [EMAIL PROTECTED]
>
> To subscribe to the Linux Newbies' List: send
> "subscribe" in the body to
[EMAIL PROTECTED]
__________________________________________________
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com
_
Philippine Linux Users Group. Web site and archives at http://plug.linux.org.ph
To leave: send "unsubscribe" in the body to [EMAIL PROTECTED]
To subscribe to the Linux Newbies' List: send "subscribe" in the body to
[EMAIL PROTECTED]