Dirk Bremer wrote:
Note the loop as shown above. What am I doing wrong? Do I need to create
a new SMTP object for each message?

You have to start each message transaction with the "MAIL FROM" SMTP command (i.e. $smtp->mail() ). You do not need to reconnect unless the server kicks you out after sending an email (some do!).

You might want to revise your code to something like:

use Net::SMTP;
$smtp = Net::SMTP->new('mailhost');

# start loop
    # Loop over the following for each message
    $smtp->mail($ENV{USER});  # <-- Start with this every time!
    $smtp->to('postmaster');
    $smtp->data();
    $smtp->datasend("To: postmaster\n");
    $smtp->datasend("\n");
    $smtp->datasend("A simple test message\n");
    $smtp->dataend();
# end loop

$smtp->quit;
# EOF

        dZ.

_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to