Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem whith Net::SMTP 1

Status
Not open for further replies.

jm35

Technical User
Dec 26, 2002
2
FR
hi,

I'm new in perl's world.Could anyone help me on the follwing script.
The probleme : I'm unable to send email when i pass more than 1 argument to the "to()" method
Here is the script
use strict;
use Net::SMTP;
my $smtp=Net::SMTP->new('my mailserver',Debug=>2) my $message=" this is a test ";
my $from="fred\@test.net";
my $nom="toto,tata \n";
my $email="user1\@yahoo.com,user2\@yahoo.com";
$smtp->mail($from);
$smtp->to($email);
$smtp->recipient($email);
$smtp->data();
$smtp->datasend("To: $nom \n ");
$smtp->datasend("\nCc: foo \n ");
$smtp->datasend("\nSubject: test smtp \n");
$smtp->datasend("\n");
$smtp->datasend($message);
$smtp->dataend();
$smtp->quit();

I get the folwong error message :
RCPT TO : <user1@yahoo.com,user2@yahoo.com>
501 Syntax error, parameters in command &quot;RCPT TO.....&quot; unrecognized or missing.
If I put these to adress directly in the to() function it works fine .like to('user1@yahoo.com','user2@yahoo.com').

Thanks in advance for your help

 
I think the addresses might need to be separated by a semicolon instead of a comma.
 
You are confusing a list of arguments, and a single argument that resembles perl syntax for creating a list...

This will work for you I think:

my @email = (&quot;user1\@yahoo.com&quot; , &quot;user2\@yahoo.com&quot;);

# and then later

$smtp->to(@email);

Notice we are using an array now, instead of scalar. Now we are passing a list of arguments, instead of a single string. This seems to be what would work based on what you said in your post:

&quot;If I put these to adress directly in the to() function it works fine .like to('user1@yahoo.com','user2@yahoo.com').&quot;

Hope this helps.

--jim
* * * Merry Christmas and Happy New Year! * * *

( Don't touch that Red Flag link you crazy freak, it's just a holiday greeting! )
 
Jim ,

Thats is the key ,it works better now.
I've declared my variable as a list instead of a scalar.

All is OK .

Thank you very much for your help.

best wishes to all of you .

J-M
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top