Home: Perl Programming Help: Intermediate:
Problem sendign SMTP to multiple addresses.


Dec 21, 2006, 8:53 AM

Views: 1172
Problem sendign SMTP to multiple addresses.

Problem sending SMTP to multiple addresses.

I have a working PERL program that when I send to one e-mail address it works fine. When I add a second e-mail address it stops working.

OS - Windows 2003 Server and Windows XP Pro.

Sections of program

use strict;

use Net::SMTP;

my $smtp;

$smtp = Net::SMTP->new('server.name.com'); # connect to an SMTP server

$smtp->mail( 'from@somehost.com' ); # use the sender's address here

$smtp->to('to@somehost.com'); # recipient's address

$smtp->data(); # Start the mail

# Send the header.

$smtp->datasend("To: to\@somehost.com");

$smtp->datasend("From: from\@somehost.com\n");

$smtp->datasend("Subject: Test e-mail");


It fails when I make the following two changes:

$smtp->to('to@somehost.com, to_Second@somehost.com'); # recipient's address

$smtp->datasend("To: to\@somehost.com, to_Second\@somehost.com");

Any help on how to get this working would be appreciated.


Dec 21, 2006, 10:59 AM

Views: 1170
Re: [alabbe] Problem sendign SMTP to multiple addresses.

sorry, I posted in wrong thread.

(This post was edited by KevinR on Dec 21, 2006, 11:01 AM)

Thaumaturge / Moderator

Jan 8, 2007, 7:47 AM

Views: 1160
Re: [alabbe] Problem sendign SMTP to multiple addresses.

In Reply To

$smtp->to('to@somehost.com, to_Second@somehost.com'); # recipient's address

According to Net::SMTP's documentation that should be:

$smtp->to('to@somehost.com', 'to_Second@somehost.com'); # recipient's address

(i.e. Each address is sent as a separate string.)

Dave Cross, Perl Hacker, Trainer and Writer
Get more help at Perl Monks