Byron Wise wrote: > --- lonh SENG <[EMAIL PROTECTED]> wrote: > > I am beginner of perl and unix system. > > I have a flat file containing email address. > > I want to send the same message to those guys in > > the flat file. > > Could anyone help me? > > This is a very basic approach that will send a text > message to everyone in your flat file: > > ## This isn't tested ;-) > > $message = "What I want to say goes here for the > body."; > > open (SENDMAIL,"|/usr/lib/sendmail -t"); > > open (EMIAL, "myFlatFile") or die "Can't open file: $!\n";
# you meant EMAIL > # Read each email address in and send it out one at a time. > while( $email = <EMAIL> ) { chomp $email; # otherwise, From: and Subject: won't be headers > print SENDMAIL "To: $email\n"; > print SENDMAIL "From: You\n"; > print SENDMAIL "Subject: Whatever you want\n\n"; > print SENDMAIL $message; > } > close (EMAIL); > close (SENDMAIL); Another option would be to place all the addresses in the same message. # likewise untested use warnings; open EMAIL, "< myemailfile" or die "can't read email file: $!\n"; push @addresses, $email while chomp($email = <EMAIL>); close EMAIL; $from = $my_address; $to = shift @addresses; $cc = join ",\n\t", @addresses; $msg = <<EOM; From: $from To: $to Cc: $cc Subject: Extra! Extra! Microsoft drops out of OS war! blah, blah, blah, this would never happen... EOM open SENDMAIL, "|$sendmail -t" or die "Can't open pipe to $sendmail: $!\n"; print SENDMAIL $msg; close SENDMAIL or die "Can't close pipe to $sendmail: $!\n"; __END__ HTH Tim -- I'm not an alien. I'm discontent. -- Stan, "The Faculty" _______________________________________________ Perl-Unix-Users mailing list. To unsubscribe go to http://listserv.ActiveState.com/mailman/subscribe/perl-unix-users