CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

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

 



alabbe
Novice

Dec 21, 2006, 8:53 AM

Post #1 of 3 (511 views)
Problem sendign SMTP to multiple addresses. Can't Post

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");

$smtp->datasend("\n");







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.


KevinR
Veteran


Dec 21, 2006, 10:59 AM

Post #2 of 3 (509 views)
Re: [alabbe] Problem sendign SMTP to multiple addresses. [In reply to] Can't Post

sorry, I posted in wrong thread.
-------------------------------------------------


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


davorg
Thaumaturge / Moderator

Jan 8, 2007, 7:47 AM

Post #3 of 3 (499 views)
Re: [alabbe] Problem sendign SMTP to multiple addresses. [In reply to] Can't Post


In Reply To

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



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


Code
$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
http://www.dave.org.uk/
Get more help at Perl Monks

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives