The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

forward to pipe error but email sent

Discussion in 'E-mail Discussions' started by rbruhn, Sep 22, 2003.

  1. rbruhn

    rbruhn Member

    Joined:
    Sep 15, 2003
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    Hello.
    We are setting up a website on a webhost were cpanel is used. The mail program is sendmail.
    I have written a perl script that parses incoming mail, inserts the data into Mysql database, retrieves the proper password for what the user purchased, and returns an email to them.

    I have the incoming mail (typically from Yahoo) forwarded to the script using |/home/erotic-/public_html/cgi-bin/ebot.pl
    I do this by actually creating a forward (not a .forward....though I have tried this as well). Every time, the email forwards to the script and works fine. The user is sent a password. But, the user also recieves the following failure message. I was wondering if anyone can give me a clue why this happens. Thanks if you are able to respond.

    ______________________________________

    This message was created automatically by mail delivery software.

    A message that you sent could not be delivered to one or more of its
    recipients. This is a permanent error. The following address(es)
    failed:

    pipe to |/home/erotic-/public_html/cgi-bin/ebot.pl
    generated by erotic-@alpha.securenet-server.net
    (ultimately generated from erotic-@eroticinducer.com)

    The following text was generated during the delivery attempt:

    ------ pipe to |/home/erotic-/public_html/cgi-bin/ebot.pl
    generated by erotic-@alpha.securenet-server.net
    (ultimately generated from erotic-@eroticinducer.com) ------


    >> e.bot... (Mon Sep 22 14:25:12 2003) ORDER: 28
    From cameron_65@yahoo.com Mon Sep 22 10:25:12 2003
    Received: from [216.136.173.81] (helo=web14305.mail.yahoo.com)
    by alpha.securenet-server.net with smtp (Exim 4.23)
    id 1A1Rcm-0008Ul-8z
    for erotic-@eroticinducer.com; Mon, 22 Sep 2003 10:25:12 -0400
    Message-ID: <20030922142454.70307.qmail@web14305.mail.yahoo.com>
    Received: from [146.201.221.70] by web14305.mail.yahoo.com via HTTP;
    Mon, 22 Sep 2003 07:24:54 PDT
    Date: Mon, 22 Sep 2003 07:24:54 -0700 (PDT)
    From: Cameron Jones <cameron_65@yahoo.com>
    Subject: money
    To: erotic-@eroticinducer.com
    MIME-Version: 1.0
    Content-Type: multipart/alternative;
    boundary="0-55094970-1064240694=:69564"
    --0-55094970-1064240694=:69564
    Content-Type: text/plain; charset=us-ascii
    Status: Money Pending
    PayDirect Receipt #: 6869654
    Sender's name: Robert Bruhn
    Sender's email: cameron_65@yahoo.com
    Message title: Male Script 1
    Message: Please send me part 2, GTOG
    Verified Address:
    Confirmation Required: no
    When to send: immediately
    Amount: $15.00
    ---------------------------------
    Do you Yahoo!?
    Yahoo! SiteBuilder - Free, easy-to-use web site design software
    --0-55094970-1064240694=:69564
    Content-Type: text/html; charset=us-ascii
    <DIV><STRONG>Status:</STRONG> Money Pending<BR><STRONG>PayDirect
    Receipt #:</STRONG> 6869654<BR><STRONG>Sender's name:</STRONG> Robert
    Bruhn<BR><STRONG>Sender's email:</STRONG>
    cameron_65@yahoo.com<BR><STRONG>Message title:</STRONG> Male Script 1<BR><STRONG>Message: </STRONG>Please
    send me part 2, GTOG<BR><STRONG>Verified Address:</STRONG>
    <BR><STRONG>Confirmation Required:</STRONG> no<BR><STRONG>When to send:</STRONG>
    immediately<BR><STRONG>Amount:</STRONG> $15.00<BR></DIV><p><hr SIZE=1>
    Do you Yahoo!?<br>
    <a
    href="http://us.rd.yahoo.com/evt=10469/*http://sitebuilder.yahoo.com">Yahoo! SiteBuilder</a> - Free, easy-to-use web site design software
    --0-55094970-1064240694=:69564--
    1 rows inserted

    ------ This is a copy of the message, including all the headers. ------

    Return-path: <cameron_65@yahoo.com>
    Received: from [216.136.173.81] (helo=web14305.mail.yahoo.com)
    by alpha.securenet-server.net with smtp (Exim 4.23)
    id 1A1Rcm-0008Ul-8z
    for erotic-@eroticinducer.com; Mon, 22 Sep 2003 10:25:12 -0400
    Message-ID: <20030922142454.70307.qmail@web14305.mail.yahoo.com>
    Received: from [146.201.221.70] by web14305.mail.yahoo.com via HTTP;
    Mon, 22 Sep 2003 07:24:54 PDT
    Date: Mon, 22 Sep 2003 07:24:54 -0700 (PDT)
    From: Cameron Jones <cameron_65@yahoo.com>
    Subject: money
    To: erotic-@eroticinducer.com
    MIME-Version: 1.0
    Content-Type: multipart/alternative;
    boundary="0-55094970-1064240694=:69564"

    --0-55094970-1064240694=:69564
    Content-Type: text/plain; charset=us-ascii

    Status: Money Pending
    PayDirect Receipt #: 6869654
    Sender's name: Robert Bruhn
    Sender's email: cameron_65@yahoo.com
    Message title: Male Script 1
    Message: Please send me part 2, GTOG
    Verified Address:
    Confirmation Required: no
    When to send: immediately
    Amount: $15.00



    ---------------------------------
    Do you Yahoo!?
    Yahoo! SiteBuilder - Free, easy-to-use web site design software
    --0-55094970-1064240694=:69564
    Content-Type: text/html; charset=us-ascii

    <DIV><STRONG>Status:</STRONG> Money Pending<BR><STRONG>PayDirect
    Receipt #:</STRONG> 6869654<BR><STRONG>Sender's name:</STRONG> Robert
    Bruhn<BR><STRONG>Sender's email:</STRONG>
    cameron_65@yahoo.com<BR><STRONG>Message title:</STRONG> Male Script 1<BR><STRONG>Message: </STRONG>Please
    send me part 2, GTOG<BR><STRONG>Verified Address:</STRONG>
    <BR><STRONG>Confirmation Required:</STRONG> no<BR><STRONG>When to send:</STRONG>
    immediately<BR><STRONG>Amount:</STRONG> $15.00<BR></DIV><p><hr SIZE=1>
    Do you Yahoo!?<br>
    <a
    href="http://us.rd.yahoo.com/evt=10469/*http://sitebuilder.yahoo.com">Yahoo! SiteBuilder</a> - Free, easy-to-use web site design software
    --0-55094970-1064240694=:69564--

    cPanel.net Support Ticket Number:
     
  2. mjm

    mjm BANNED

    Joined:
    Aug 1, 2003
    Messages:
    69
    Likes Received:
    0
    Trophy Points:
    6
    cant really help, but it might be a good idea to turn off directory indexing. i can view all files in /orders ;)

    cPanel.net Support Ticket Number:
     
  3. Stefaans

    Stefaans Well-Known Member

    Joined:
    Mar 5, 2002
    Messages:
    451
    Likes Received:
    2
    Trophy Points:
    18
    Location:
    Vancouver, Canada
    I recently had a similar problem with a PHP script piping email. The pipe worked great but I kept on getting the error message as well. Eventually fixed it by running PHP in quiet mode.

    Have no idea what you should do with a Perl script, but try executing with warnings diabled ;)

    cPanel.net Support Ticket Number:
     
  4. rbruhn

    rbruhn Member

    Joined:
    Sep 15, 2003
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    ill give it a shot and see what happens. I'm not to fluent in perl so I'll have to search for an answer. I'll post if I find anything that works so people in the future can refer to it. Thanks Stefaans.

    In the mean time, if anyone else has suggestions. I'm open to them.

    mjm - Your right. I should turn off the index. I just set this site up for my friend to test everything before moving anything critical over. All the orders you saw were tests. Not much in any of the other folders.
    But point well taken. lol.

    cPanel.net Support Ticket Number:
     
  5. rbruhn

    rbruhn Member

    Joined:
    Sep 15, 2003
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    well, tried implementing a warning supression but that failed. Anybody?

    Here is the perl code I'm using. Pulled it off the web from someone. Oh yeah...wrote to them and could only get a "it should work" reply. "deleted" means I changed pertinent information.

    #!/usr/bin/perl
    # Use the Database Interface Library
    #------------------------------------
    use DBI;
    my $err = 0; # Current error number

    # Print start-up msg
    #---------------------
    my $t=gmtime();
    print "\n>> e.bot... ($t) ";

    # Open count file - stores the current order number
    #---------------------------------------------------
    my $cnt;
    open (CNT, '+</home/deleted/count');
    read (CNT, $cnt, 10);
    seek (CNT, 0, 0);
    print CNT ++($cnt);
    close (CNT);
    print "ORDER: $cnt\n";

    # Open log file and record everything into it
    #----------------------------------------------
    open (OUT, ">/home/deleted.$cnt");
    while (<STDIN>) {
    next if /^\s*$/;
    print OUT $_;
    print;
    chomp;

    if (/Status: /) { $status = $'; }
    if (/PayDirect Receipt #: /) { $receipt = $'; }
    if (/Sender's name: /) { $name = $'; }
    if (/Sender's email: /) { $email_addr = $'; }
    if (/Message title: /) { $prod_id = $'; }
    if (/Amount: /) { $price = $'; }
    }

    # Strip out whitespace
    #----------------------
    for ($status) { s/^\s+//; s/\s+$//; }
    for ($receipt) { s/^\s+//; s/\s+$//; }
    for ($name) { s/^\s+//; s/\s+$//; }
    for ($email_addr) { s/^\s+//; s/\s+$//; }
    for ($prod_id) { s/^\s+//; s/\s+$//; }
    for ($price) { s/^\s+//; s/\s+$//; }

    # Check the essentials are there...
    #-----------------------------------
    if (!$receipt) { $err_txt[$err++]="No order id\n"; }
    if (!$prod_id) { $err_txt[$err++]="No product id\n"; }
    if (!$email_addr) { $err_txt[$err++]="No email address\n"; }
    if (!$price) { $err_txt[$err++]="No total price\n"; }

    # Connect the DB
    #-----------------
    $dbh = DBI->connect("DBI:mysql:deleted:localhost","deleted","deleted");

    # Insert the data
    #-----------------
    $statement = "insert into orders (counter, status, receipt, name, email_addr, prod_id, price)";
    $statement .= "values ($cnt, \"$status\", \"$receipt\", \"$name\", \"$email_addr\", \"$prod_id\", \"$price\")";
    $sth = $dbh->prepare($statement) or print "Can't prepare the SQL\n";
    $rv = $sth->execute or print "Can't execute the query: $sth->errstr";
    print $rv, " rows inserted\n";

    # Get the product password from the DB
    #---------------------------------------
    $statement = "select password from products where prod_id =\"$prod_id\"";
    $sth = $dbh->prepare($statement) or print "Can't prepare the SQL\n";
    $rv = $sth->execute or print "Can't execute the query: $sth->errstr";
    if ($rv == '0E0') { $err_txt[$err++]="Product not found\n"; }
    @row = $sth->fetchrow_array;
    $sth->finish;

    # If any errors...
    #------------------
    if ($err) {
    if ($email_addr) {
    &send_mail ($email_addr, "Error in Order!", "Dear Customer,\nThe following errors occurred while processing your order:\n\n@err_txt\n\nA human will process your order within the next few days. We apologise for the delay.\n\nThanks\n\n");
    }
    print "$err errors!: \n@err_txt";
    }

    # Success! Send password etc. to customer.
    #-------------------------------------------
    else {
    &send_mail($email_addr, "Your Password...", "Dear Customer,\nThankyou for your order. \n\nYour password is: $row[0].\n If you have any problems, please contact us: \n\nsales\@eroticinducer.com");
    }

    $dbh->disconnect;

    #-----------------------
    # Subroutine: send_mail
    #------------------------
    sub send_mail {
    open(MAIL, "|/usr/sbin/sendmail -t") || die ("FATAL: Failed open mail!: $!\n");
    print MAIL <<"EOM";
    To: $_[0]
    Subject: $_[1]
    From: Sales <sales\@eroticinducer.com
    Sender: e\bot\@eroticinducer.com
    Reply-To: sales\@eroticinducer.com\n
    $_[2]
    \n.\n
    EOM
    close (MAIL)
    }

    cPanel.net Support Ticket Number:
     
  6. Stefaans

    Stefaans Well-Known Member

    Joined:
    Mar 5, 2002
    Messages:
    451
    Likes Received:
    2
    Trophy Points:
    18
    Location:
    Vancouver, Canada
    I meant something like #!/usr/bin/perl -X in the first line. In my PHP scripts I use #!/usr/bin/pphp -q.

    cPanel.net Support Ticket Number:
     
  7. rbruhn

    rbruhn Member

    Joined:
    Sep 15, 2003
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    Tried it. Didn't work. Thanks for the suggestion Stefaans.

    cPanel.net Support Ticket Number:
     
  8. Stefaans

    Stefaans Well-Known Member

    Joined:
    Mar 5, 2002
    Messages:
    451
    Likes Received:
    2
    Trophy Points:
    18
    Location:
    Vancouver, Canada
    One last comment before I shut up. Check for blank lines after the last characters of code - they could be causing echos.

    OK, now I wil shut up. Good luck ;)

    cPanel.net Support Ticket Number:
     
  9. rbruhn

    rbruhn Member

    Joined:
    Sep 15, 2003
    Messages:
    5
    Likes Received:
    0
    Trophy Points:
    1
    Well, in case anyone is interested the problem has been solved. I wrote an email to support at my webhost telling them of the problem. Their very fast reply was:

    "Sendmail is current and should not be the root cause of any errors. We do not get involved in web development or script troubleshooting. That is beyond the scope of normal hosting support."

    My response back:

    "but sendmail IS under your hosting support since you don't allow root access to the program. I don't need troubleshooting of the script or webdesign. The problem IS with the email routing or something else on your system. If it was the script, then the script would not have sent back a perfectly good response."

    I was getting testy at this point.

    Their reply:

    "Sendmail would not be the cause for bouncing emails. Where should the email go? Emails must go somewhere. Try making an account within cpanel for the script account. "

    Which of course, is totally irrelevant to the point. I made an email account and I'm trying to forward it to that script.
    My reply:
    "Yes, the email needs to go somewhere. And it does. It goes to the script, and the script runs it. Perfectly. Yet, the user also gets an error saying the email did not get sent to the script. Sounds like a routing problem"

    Their reply:
    1. "Your issue has been forwarded to a senior technical advisor for review."
    Next reply:
    2: "Issue has been resolved. Thanks and have a great day."

    And now it works. I looked at my script and emails nothing has changed. I sent an email asking for what the problem was but have not got a response so I don't know what the ultimate cause is. All I can say is after trying everything else you can think of give your webhost a shout or two, or three, and maybe they'll listen eventually.

    Sorry for the long post.

    cPanel.net Support Ticket Number:
     
Loading...

Share This Page