Re: Net::SMTP Question

2006-02-03 Thread DZ-Jay

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


RE: Net::SMTP Question

2006-02-03 Thread Dirk Bremer
 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-Jay wins the Friday's Best Answer Award for this week. I have many
programs that send single email messages, but none that needed to send
multiple until now. His advice as stated above worked perfectly. The
documentation for Net::SMTP is rather sparse and doesn't address this
situation. DZ-Jay has his choice of a virtual-6-pack or a virtual bottle
of reserve for his great response. 

Dirk Bremer - Senior Systems Engineer - ESS/AMS - NISC Lake St. Louis MO
- USA Central Time Zone
636-755-2652 fax 636-755-2503

[EMAIL PROTECTED]
www.nisc.coop 

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