Perl

Moderators: Jonathan
Number of threads: 1259
Number of posts: 3644

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
perl problem Posted by thlware on 25 Jan 2005 at 2:31 AM
Hi have a perl script that uses Net::SMTP everything is working fine
no sytax error when i run the script with perl -c <scriptname.pl> but i don't get the results i expected there is nothing showing on the subject and from field everything is send to the message body.I think is a logical error. please assist. Below is the output on my outlook client and the code that generate that.And the scrip[t runns on a linux machine with Perl -v 5.8.4


==Output=== Note that the From and Subject fields are empty

From: To:someone@domainname.co.za
Subject:


From: helpdesk@Support.enerweb.co.za
Subject: ID476:CT - Investigating cases of 59 minute dialups
Message:New Ticket Logged
(Status:Unassigned <===> GOTO: https://www.enerweb.co.za/helpdesk/supporter)

===output======

====Perl Script on the linux Box"

#!/usr/bin/perl5
use DBI;
use Net::SMTP;
my $gfDebug = 1;
my $gfsnDebug =1;

sub notify_group{
my ($to_adr,$subject,$message)= @_;
my $subject =("ID$id\:$short");

my $message ="New Ticket Logged\n(Status:$status <===> GOTO: $supporter_site_url)\n";
my $sender ='help@meandsomeone.co.za';
my $SMTP_SERVER = 'mail.somorg.co.za';

$smtp = Net::SMTP-> new ($SMTP_SERVER,
Hello => $SMTP_SERVER,
Timeout => 60,
Debug => 0);
if ($smtp) {
print("SMTP Connection OK...\n") if ($gfDebug == 1);
$smtp->mail($sender); # ... from sysadm
$smtp->to($to_adr); # to sysadm's mail address
$smtp->data();
$smtp->datasend("To: ".$to_adr."");
$smtp->datasend("From: ".$sender."\n");
$smtp->datasend("Subject: ".$subject."\n");
$smtp->dataend("\n");
$smtp->datasend("Message:". $message." \n");
$smtp->dataend("\n");

$smtp->quit;

print("SMTP Done...\n") if ($gfDebug == 1);
1; # all went well
}else {
print("SMTP Failure...\n") if ($gfDebug == 1);
0; # something went wrong
}
}

the above is my sub routine that i call when i send an email.

Thanx
chz
Report
Re: perl problem Posted by Xfactor on 27 Jan 2005 at 2:34 AM
: Hi have a perl script that uses Net::SMTP everything is working fine
: no sytax error when i run the script with perl -c <scriptname.pl> but i don't get the results i expected there is nothing showing on the subject and from field everything is send to the message body.I think is a logical error. please assist. Below is the output on my outlook client and the code that generate that.And the scrip[t runns on a linux machine with Perl -v 5.8.4
:
:
: ==Output=== Note that the From and Subject fields are empty
:
: From: To:someone@domainname.co.za
: Subject:
:
:
: From: helpdesk@Support.enerweb.co.za
: Subject: ID476:CT - Investigating cases of 59 minute dialups
: Message:New Ticket Logged
: (Status:Unassigned <===> GOTO: https://www.enerweb.co.za/helpdesk/supporter)
:
: ===output======
:
: ====Perl Script on the linux Box"
:
: #!/usr/bin/perl5
: use DBI;
: use Net::SMTP;
: my $gfDebug = 1;
: my $gfsnDebug =1;
:
: sub notify_group{
: my ($to_adr,$subject,$message)= @_;
: my $subject =("ID$id\:$short");
:
: my $message ="New Ticket Logged\n(Status:$status <===> GOTO: $supporter_site_url)\n";
: my $sender ='help@meandsomeone.co.za';
: my $SMTP_SERVER = 'mail.somorg.co.za';
:
: $smtp = Net::SMTP-> new ($SMTP_SERVER,
: Hello => $SMTP_SERVER,
: Timeout => 60,
: Debug => 0);
: if ($smtp) {
: print("SMTP Connection OK...\n") if ($gfDebug == 1);
: $smtp->mail($sender); # ... from sysadm
: $smtp->to($to_adr); # to sysadm's mail address
: $smtp->data();
: $smtp->datasend("To: ".$to_adr."");
: $smtp->datasend("From: ".$sender."\n");
: $smtp->datasend("Subject: ".$subject."\n");
: $smtp->dataend("\n");
: $smtp->datasend("Message:". $message." \n");
: $smtp->dataend("\n");
:
: $smtp->quit;
:
: print("SMTP Done...\n") if ($gfDebug == 1);
: 1; # all went well
: }else {
: print("SMTP Failure...\n") if ($gfDebug == 1);
: 0; # something went wrong
: }
: }
:
: the above is my sub routine that i call when i send an email.
:
: Thanx
: chz

Here's what I see. I haven't tested this but here are a couple of things to try.

In your datasend messages, you are using double quotes inside the function. You probably only need to quote the whole thing once. Also You don't have a newline after the To field. Here's the part of code I'd change:

$smtp->datasend("From: $sender"\n");
$smtp->datasend("To: $to_adr\n");
$smtp->datasend("Subject: $subject\n");
$smtp->dataend("\n");
$smtp->datasend("Message: $message\n");
$smtp->dataend("\n");

I hope this helps.

X



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.