On 5/11/02 9:05 PM, Troy May <[EMAIL PROTECTED]> wrote:

> Hello,
> 
> I'm trying to figure out how to send emails through Sendmail with an email
> list that could change at any given time.  I'm trying it with a text file
> now:  (file is in this format: email, email, email, email)
> 
> ---------------------------------------------
> $mailprog = '/usr/sbin/sendmail';
> $recipient = '/path/to/email.txt';
> open (MAIL, "|$mailprog -t") or dienice("Can't access $mailprog!\n");
> print MAIL "BCC: $recipient\n";
> print MAIL "Reply-to: tmay\@sierrasoho.org\n";
> print MAIL "Subject: Testing\n\n";
> print MAIL <<End1;
> Testing
> End1
> close(MAIL);
> ----------------------------------------------
> 
> It does not work.

That's because you're trying to send something to '/path/to/email.txt' :)

> <snip>
> Any ideas?

What about something like:

##### code #####

my $mailprog = '/usr/sbin/sendmail';
my $mailfile = '/path/to/email.txt';

open(MAILFILE, $mailfile);

# assuming all your emails are on one line
my @emails = split(', ', <MAILFILE>);

close(MAILFILE);

# loop through each address and send them an email
foreach my $email (@emails){

    open (MAIL, "|$mailprog -t") or dienice("Can't access $mailprog!\n");
    print MAIL "To: $email\n";
    print MAIL "Reply-to: tmay\@sierrasoho.org\n";
    print MAIL "Subject: Testing\n\n";
    print MAIL <<END1;
Testing
END1
    close(MAIL);

}

##### end code #####

That should work, although I haven't tested it. It should send a separate
email to each person on the list.

hth,
-- 
Michael


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to