Hello all,

I need your help.

I made this simple script for use with html forms.

#!/usr/bin/perl use Net::SMTP; use CGI qw(:standard); #---------------Configuration section----------------# $to="info\@domainname"; #---------------Configuration section ends-----------# #--------------Initialization section----------------# $name=param("name"); $surname=param("surname"); $subject=param("subject"); $comments=param("comments"); $company=param("company"); $phone=param("phone"); $fax=param("fax"); $email=param("email");; #--------------Initialization section ends-----------# ###### required fields check $check=1; if (!$name) {$check="0";} elsif (!$surname) {$check="0";} elsif (!subject) {$check="0";} elsif (!email) {$check="0";} else { ###### required fields check ends here $smtp = Net::SMTP->new('localhost'); $smtp->mail("Mail from Website"); $smtp->to("$to"); $smtp->data(); $smtp->datasend("FROM: Mail from Website\n"); $smtp->datasend("TO: $to\n"); $smtp->datasend("SUBJECT: $subject\n"); $smtp->datasend("\n"); $smtp->datasend("NAME: $name\n"); $smtp->datasend("SURNAME: $surname\n"); $smtp->datasend("SUBJECT: $subject\n"); $smtp->datasend("COMMENTS:\n\n$comments\n\n"); $smtp->datasend("COMPANY: $company\n"); $smtp->datasend("PHONE: $phone\n"); $smtp->datasend("FAX: $fax\n"); $smtp->datasend("E-MAIL: $email\n"); $smtp->dataend(); $smtp->quit; } if ($check=="0") { print "Content-type: text/html;", "\n\n"; print << 'ERRORMSG'; <html> <head> <title> E-mail status </title> <style type="text/css"> P {font-family: Arial; font-size: 14pt;font-weight: bold; color: #353B +37;} </style> </head> <body bgcolor="#ffffff"> <table width="100%" height="100%"> <tr> <td align="center"><P><img src="images/error.jpg" border="0" h +space="0" vspace="0">Please Fill All REQUIRED Forms<br><br><P><img src="images/error.jpg" border="0" hspace="0" vspa +ce="0">Παρακαλώ συμπληρώσατε όλα τα απαιτούμενα πεδία</P></td> </tr> </table> </body> </html> ERRORMSG } else { print "Content-type: text/html;", "\n\n"; print << 'OKMSG'; <html> <head> <title> E-mail status </title> <style type="text/css"> P {font-family: Arial; font-size: 14pt;font-weight: bold; color: #353B +37;} </style> </head> <body bgcolor="#ffffff"> <table width="100%" height="100%"> <tr> <td align="center"><P><img src="images/ok.jpg" border="0" hspace=" +0" vspace="0"> Message sent successfully<br><br><img src="images/ok.jpg" bord +er="0" hspace="0" vspace="0">To E-mail σας στάλθηκε επιτυχώς</P> </td> </tr> </table> </body> </html> OKMSG }

When required fields are not filled response comes in a few seconds. But if everything is ok and mail is going to be sent response comes after 2 or more minutes.

Does anybody know where is my mistake ?

Thanks

In reply to Net::SMTP - too much delay... by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.