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.

[HELP] Imap problem after conversion

Discussion in 'General Discussion' started by edyst37, Oct 26, 2005.

  1. edyst37

    edyst37 Registered

    Joined:
    Mar 10, 2004
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    151
    One of my client is having problem using imap after we performed the maildir conversion. Please advise how should we solve this problem. thank you so much.

    the problem is listed below:

    Hi, I have been using the imap functions to filter mail message and process customer order, but it started
    having error few days ago.

    ERROR:
    Warning: imap_open(): Couldn't open stream {localhost} in
    /home/mamashop/public_html/system/bill/clean_mamashop@mama-shop.com.phtml on
    line 24

    Warning: imap_open(): Couldn't open stream {localhost} in /public_html/system/bill/clean_mamashop@mama-shop.com.phtml on line 24
    Total Mails: 0

    Warning: imap_expunge(): supplied argument is not a valid imap resource in /public_html/system/bill/clean_mamashop@mama-shop.com.phtml on line 152

    Warning: imap_close(): supplied argument is not a valid imap resource in /public_html/system/bill/clean_mamashop@mama-shop.com.phtml on line 153
     
  2. edyst37

    edyst37 Registered

    Joined:
    Mar 10, 2004
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    151
    The code of the page is listed below

    <?
    if($REMOTE_USER!="vincent"){
    echo "Access Denied";
    exit;
    }

    include_once("_dbconnect.phtml");
    $today=date("Y-m-d h:n:s");

    $userid="*******";

    $ary = array("99","112","116","106","109","109","117");
    $i=0;
    while($ary[$i]){
    $N=$ary[$i]-$i;
    $C= chr($N);
    $pwd .="$C";
    $i++;
    }

    $pwd="********";

    $mybox="{localhost}";
    $mbox=imap_open ($mybox,$userid,$pwd);
    $headers = @imap_headers($mbox);
    $max=@sizeof($headers);

    echo "Total Mails: $max <br>";

    $x=$max;

    if($step=="Delete"){
    $n=0;
    while($id[$n]){
    imap_delete($mbox,$id[$n]);
    echo "Deleted $id[$n] ";
    $n++;
    }
    echo "<br><a href=$PHP_SELF>Reload</a><hr><br>";
    imap_expunge ($mbox);
    imap_close($mbox);
    exit;
    }




    while ($x>=1) {
    /*

    $header=@imap_header($mbox,$x);

    $body=NULL;
    $BODY=NULL;
    if($max<1000){
    $BODY=imap_body($mbox,$x);
    $BODY=strtoupper($BODY);
    $body=$BODY;

    $body=chop(trim(strip_tags($body)));
    $body=substr($body,0,5000);

    $body = str_replace("VINCENT","<span style=background-color:yellow>Vincent</span>",$body);
    $body = str_replace("PANG","<span style=background-color:yellow>Pang</span>",$body);
    $body = str_replace("MICHELLE","<span style=background-color:yellow>Michelle</span>",$body);
    $body = str_replace("CCNOW","<span style=background-color:yellow>CCNOW</span>",$body);
    $body = str_replace("PAYPAL","<span style=background-color:yellow>PAYPAL</span>",$body);
    $body = str_replace("SUN CHEOW","<span style=background-color:red>Sun Cheow</span>",$body);
    $body = str_replace("CONDOM","<span style=background-color:grey>CONDOM</span>",$body);

    }
    $from=$header->from;
    $to=$header->to;

    if (is_array($from)){
    $i=0;
    while(list($key, $val) = each($from)) {
    $Person=$from[$i]->personal;
    $from[$i]->adl;
    $Person=$from[$i]->mailbox;
    $Host=$from[$i]->host;
    $mailfrom .= "$Person@$Host ::";
    $i++;
    }
    }

    if (is_array($to)){
    $i=0;
    while(list($key, $val) = each($to)) {
    $towho=$to[$i]->mailbox;
    $tohost=$to[$i]->host;
    $mailto .= "$towho@$tohost ::";
    $i++;
    }
    }

    //$mailfrom="$Person@$Host";
    //$mailto="$towho@$tohost";

    $SUBJECT=strtoupper($header->subject);
    $SUBJECT=strip_tags($SUBJECT);
    $SUBJECT=chop(trim($SUBJECT));
    $SUBJECT=str_replace("\n"," ",$SUBJECT);
    $SUBJECT=str_replace(" "," ",$SUBJECT);
    $short_sub = substr($SUBJECT,0,1000);
    $short_sub = strtolower($short_sub);



    if(!strpos(" $SUBJECT","CCNOW") && !strpos(" $BODY","CCNOW")
    && !strpos(" $SUBJECT","VINCENT") && !strpos(" $BODY","VINCENT")
    && !strpos(" $SUBJECT","MICHELLE") && !strpos(" $BODY","MICHELLE")
    && !strpos(" $SUBJECT","SUN CHEOW") && !strpos(" $BODY","SUN CHEOW")
    && !strpos(" $SUBJECT","MUN YEE") && !strpos(" $BODY","MUN YEE")
    && !strpos(" $SUBJECT","CONDOM") && !strpos(" $BODY","CONDOM")
    && !strpos(" $SUBJECT","CCNOW") && !strpos(" $BODY","CCNOW")){



    if((!strpos(" $BODY","CONDOM") && !strpos(" $BODY","MAMA-SHOP")
    && !strpos(" $BODY","ORDER") && !strpos(" $BODY","CCNOW")
    && !strpos(" $BODY","XXXOR") && !strpos(" $BODY","MUN YEE")
    && !strpos(" $BODY","DRCONDOM") && !strpos(" $BODY","SGDOMAIN")
    && !strpos(" $BODY","PANGX") && !strpos(" $BODY","SUN CHEOW"))
    || (strpos(" $BODY","SPAM DETECT") || strpos(" $BODY","ENLARGE"))){
    $del_no++;
    $del_mail .= "$del_no )REMOVE $SUBJECT $body <br>";
    imap_delete($mbox,$x);
    }else{
    $rem_no++;
    $rem_mail .= "<INPUT TYPE=CHECKBOX NAME=id[] value=$x checked><b>$rem_no )$SUBJECT </b><br>";
    $rem_mail .= "<font color=blue>From: $mailfrom </font><font color=red>To: $mailto </font><br>";
    }

    */
    $rem_mail .= "$short_sub $body <br>";

    $mailfrom="";
    $mailto="";

    imap_delete($mbox,$x);
    $x--;
    }

    echo "<font size=2 face=Arial>";
    echo "$del_mail";
    echo "<form action=$PHP_SELF method=post>";
    echo "$rem_mail";
    echo "<input type=submit value=Delete name=step>";
    echo "</form>";
    echo "</font>";

    imap_expunge ($mbox);
    imap_close($mbox);

    $subject="Cleared ".$max." mails on ".date("d-m-y H:i:s");

    mail("vincent@sevenasia.com",$subject,"");


    ?>
     
  3. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,472
    Likes Received:
    20
    Trophy Points:
    463
    Location:
    Go on, have a guess
    Try using the following format when you generate the $mybox variable:

    $mybox="{localhost:110/pop3/notls}";

    or:

    $mybox="{localhost:443/imap/notls}";
     
  4. edyst37

    edyst37 Registered

    Joined:
    Mar 10, 2004
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    151
    Problem fixed, thank you very much!
     
Loading...

Share This Page