www.webdeveloper.com
Results 1 to 2 of 2

Thread: Script Problem

  1. #1
    Join Date
    Apr 2004
    Location
    India
    Posts
    35

    Script Problem

    I want to know that this script has some error. It does not send the email to me. What is the problem ?

    I call the script as

    <img src="pixel.cgi">

    Script is

    #!/usr/bin/perl


    &Printimage;
    &SendSubmission;

    sub Printimage {
    open IMAGE, "pixel.gif";
    #assume is a jpeg...
    my ($image, $buff);
    while(read IMAGE, $buff, 1024) {
    $image .= $buff;
    }
    close IMAGE;
    print "Content-type: image/gif\n\n";
    print $image;
    }
    close (IMAGE);
    }
    exit;

    sub SendSubmission {
    print "Content-type: text/html\n\n";

    $sendto = 'saud@vfemail.net';

    $mailprgm = '/usr/sbin/sendmail -t';

    $page = $ENV{'DOCUMENT_NAME'};
    $sitename = $ENV{'SERVER_NAME'};
    $client = $ENV{'HTTP_USER_AGENT'};
    $camefrom = $ENV{'HTTP_REFERER'};
    $addrin = $ENV{'REMOTE_ADDR'};
    @ip = split (/\./, $addrin);
    $binip = pack ("C4", @ip);
    $isp = gethostbyaddr ($binip, 2);
    exit;

    {

    open (MAIL, "|$mailprgm") || die 'Could not open mail program';
    print MAIL "To: $sendto\n";
    print MAIL "Subject: Visitor Alert\n";
    print MAIL "From: Visitor Alert\n";
    print MAIL "\n";
    print MAIL "Visitor Alert\n\n";
    print MAIL "A visitor from: $isp ($addrin)\n\n";
    print MAIL "OS and browser: $client\n\n";
    print MAIL "Page name: $page\n\n";
    print MAIL "The visitor came from: $camefrom\n\n";
    print MAIL "Page visited: $sitename\n\n";
    close (MAIL);

    }
    }

    exit;
    Saud Iqbal


    VME
    Saud

  2. #2
    Join Date
    Jan 2003
    Location
    USA
    Posts
    687
    ...try this:

    Code:
    #!/usr/bin/perl
    
    &Printimage;
    &SendSubmission;
    exit;
    
    sub Printimage {
    open IMAGE, "pixel.gif";
    my ($image, $buff);
        while(read IMAGE, $buff, 1024) {
            $image .= $buff;
        }
    close (IMAGE);
    print "Content-Type: image/gif\n\n";
    print $image;
    }
    
    sub SendSubmission {
    $sendto = 'saud@vfemail.net';
    $mailprgm = '/usr/sbin/sendmail -t';
    $page = $ENV{'DOCUMENT_NAME'};
    $sitename = $ENV{'SERVER_NAME'};
    $client = $ENV{'HTTP_USER_AGENT'};
    $camefrom = $ENV{'HTTP_REFERER'};
    $addrin = $ENV{'REMOTE_ADDR'};
    @ip = split (/\./, $addrin);
    $binip = pack ("C4", @ip);
    $isp = gethostbyaddr ($binip, 2);
    
    open (MAIL, "|$mailprgm") || die 'Could not open mail program';
    print MAIL "To: $sendto\n";
    print MAIL "Subject: Visitor Alert\n";
    print MAIL "From: Visitor Alert\n";
    print MAIL "\n";
    print MAIL "Visitor Alert\n\n";
    print MAIL "A visitor from: $isp ($addrin)\n\n";
    print MAIL "OS and browser: $client\n\n";
    print MAIL "Page name: $page\n\n";
    print MAIL "The visitor came from: $camefrom\n\n";
    print MAIL "Page visited: $sitename\n\n";
    close (MAIL);
    }
    Last edited by CyCo; 06-07-2004 at 06:20 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles