perl problem

Hi have a perl script that uses Net::SMTP everything is working fine
no sytax error when i run the script with perl -c 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
(Status:$status <===> GOTO: $supporter_site_url)
";
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...
") 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."
");
$smtp->datasend("Subject: ".$subject."
");
$smtp->dataend("
");
$smtp->datasend("Message:". $message."
");
$smtp->dataend("
");

$smtp->quit;

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

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

Thanx
chz

Comments

  • : Hi have a perl script that uses Net::SMTP everything is working fine
    : no sytax error when i run the script with perl -c 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
    (Status:$status <===> GOTO: $supporter_site_url)
    ";
    : 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...
    ") 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."
    ");
    : $smtp->datasend("Subject: ".$subject."
    ");
    : $smtp->dataend("
    ");
    : $smtp->datasend("Message:". $message."
    ");
    : $smtp->dataend("
    ");
    :
    : $smtp->quit;
    :
    : print("SMTP Done...
    ") if ($gfDebug == 1);
    : 1; # all went well
    : }else {
    : print("SMTP Failure...
    ") 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"
    ");
    $smtp->datasend("To: $to_adr
    ");
    $smtp->datasend("Subject: $subject
    ");
    $smtp->dataend("
    ");
    $smtp->datasend("Message: $message
    ");
    $smtp->dataend("
    ");

    I hope this helps.

    X
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion