My emailcleaning suggesties

Status
Niet open voor verdere reacties.

kenikavanbis

Terugkerende gebruiker
Lid geworden
22 mei 2007
Berichten
2.191
wat is de bedoeling dat mijn adressen kunnen worden gekuist van rommel al ik geen zin heb in nieuwsbrieven ectra

enig probleem is dat ik de sequence nog niet heb kunnen doorgronden heb zodat ik moeilijk een opéénvolgende lijst kan maken om te kunnen pagineren

suggesties om een verbetering door te voeren is altijd welkom.
PHP:
    	include"./Email/MyImapCleanup.inc";
    $imaptest = new MyImapCleanup('pop3server',true);
    $imaptest->loginpop3("yourmail@mydomain.be","***");
    //"facebookmail.com",
    $domains = array("agnithazorg.nl","media-saturn.com",
    "2dehands.be","dlapawelka.com.pl","openbare-verkopen.be","inc.com","Inc.com","netlogmail.com","belfius.be",
    "my-nwa.com","perez.it","hotmail.co.th","twoomail.com","mail.nieuwsblad.be","wtmlimited.com","marisartravel.net","huxley.be",
    "24plus.be","huxley.com","medhur51.gotadsl.co.uk","lists.chamilo.org","IO-Auctions.com","yzplas.com","ecoburotic.com",
    "nordnet.fr","kbs.gov.my","netmeans.net","csr.be","prettyindustry.com","akros-solutions.com","partslist.to",
    "teamdiamond.biz","4alpha.com","mail.ameriprise.com","progressiverecruitment.com","3d-ict.be","weathersafe.com.au","nmt.edu",
    "aristo.com.bd",".MISSING-HOST-NAME.","mail121.us2.mcsv.net","swiftvalued@yahoo.com","verizon.net","indinox.be","miaoke.us","aol.com",
    "scg.com","msdlt.k12.in.us");
    $imaptest->setEdomainsToDEL($domains);
    $emailadresses = array("sales@communitysa.com","info@yoko-ono.be","news@mailing.bnpparibasfortis.be",
    "nieuwsblad@promotie.nieuwsblad.be","pho.vsilveer@yahoo.com","chen@mail.com",
    "avaaz@avaaz.org","messages-noreply@bounce.linkedin.com","service@visaeurope.fr","service@globetravel.it",
    "pablo@jazzenede.ccsend.com","MAILER-DAEMON@secure-mail.be","sofie@3d-ict.be","chenhl@uw.edu","securite@service.at",
    "administrador@etman.com.ar","noreply@belgievacature.be","no-replys@belfius.be","firmajsedik@yahoo.com",
    "advertising@itjobboard.be","teng_dai@yzplas.com","paypal@dpaypal.be","mailservice@troostwijkauctions.com","e-magazine@eventplanner.be",
    "mailings@emails.nwruk.com","mailing@troostwijk.be","noreply@di-bag.com","haau_001@hotmail.com","belfiusbank@intl.be",
    "newsletter@daslight.com","lezersservice@mediafin.be");//,"watchguard.com"
    $imaptest->setEMailsAdressesToDEL($emailadresses);
    $imaptest->checkForToDeleteEmails(5,450);
//$imaptest->deleteSelection();//uncomment if you wil delete the selection


PHP:
<?php
    //Catchable fatal error: Object of class stdClass could not be converted to string in E:\_A_servers\xampp\htdocs\myhome\autositesvn\autosite --username DJDataB@gmail.com\ autositeV2.8\function\Email\Imap.inc on line 32 Call Stack: 0.0019 344264 1. {main}() E:\_A_servers\xampp\htdocs\myhome\autositesvn\autosite --username DJDataB@gmail.com\ autositeV2.8\function\Email\Imap.inc:0 1.8671 345296 2. MyImap->readheader() E:\_A_servers\xampp\htdocs\myhome\autositesvn\autosite --username DJDataB@gmail.com\ autositeV2.8\function\Email\Imap.inc:4 
	class MyImapCleanup{
	   private $host;
       private $port =110;
       private $MyOpenMailBox;
       private $debug;
       private $adresses;
       private $isDomainsToDel;
       private $DomainsToDel;
       private $isEmailsToDel;
       private $EmailsToDel;
       private $Headertags;
       private $msgNrToDelete =array();
       public function __construct($host,$debug= false) {
           $this->host = $host;
           $this->debug = $debug;
       }
       public function loginpop3($user,$pwx){///novalidate-cert
            $this->port=110;
            if($this->debug){print"{".$this->host.":".$this->port."}".$user."*******";}//.$pwx};
            return($this->MyOpenMailBox = imap_open("{".$this->host.":".$this->port."/pop3/novalidate-cert}",$user,$pwx));//or die(new Exception("connection failed"));
       }
       public function loginImap($user,$pwx){///novalidate-cert
            $this->port=143;
            if($this->debug){print"{".$this->host.":".$this->port."}".$user."*******";}//.$pwx};
            return($this->MyOpenMailBox = imap_open("{".$this->host.":".$this->port."}INBOX",$user,$pwx));//or die(new Exception("connection failed"));
       }
       public function setAdresses($array){
            $this->adresses = $array;
       }
       public function setHeadertags($array){
            $this->Headertags = $array;
       }
       public function checkForToDeleteEmails($start=1,$length){
            $this->validateInputs();
            if(isset($this->MyOpenMailBox)&&$headers = imap_check($this->MyOpenMailBox)){
                $endnr =$headers->Nmsgs;
                if($mails =imap_fetch_overview($this->MyOpenMailBox,"$start:$length",0)){
                    foreach($mails as $mailnr => $mailcontent){
                        if(++$mailnr>=0 && $Actiefmailheader = imap_header($this->MyOpenMailBox,$mailnr)){
                            if($this->MustEmailDeleteFromHead($Actiefmailheader)){
                                imap_delete($this->MyOpenMailBox,$mailnr);
                                $Actiefmailheader = imap_header($this->MyOpenMailBox,$mailnr);
                                //print($mailnr);
                                //$this->debugprint($Actiefmailheader);
                                $this->printHeader($Actiefmailheader);
                            }else{
                               // print_r($Actiefmailheader->sender);
                                //$this->debugprint($Actiefmailheader);
                                $this->printHeader($Actiefmailheader);
                            }
                        }
                    }
                }
            }
       }
       private function validateInputs(){
            $this->isDomainsToDel = is_array($this->DomainsToDel);
            $this->isEmailsToDel = is_array($this->EmailsToDel);
       }
       public function deleteSelection(){
            imap_expunge($this->MyOpenMailBox);
       }
       public function MustEmailDeleteFromHead($header){
            return $this->isDomainInCleaningList($header->sender[0]->host)||
            $this->isEmailInCleaningList($header->sender[0]->mailbox."@".$header->sender[0]->host);
       }
       private function isDomainInCleaningList($domain){
            return $this->isDomainsToDel && in_array($domain,$this->DomainsToDel);
       }
       private function isEmailInCleaningList($domain){
            return $this->isEmailsToDel && in_array($domain,$this->EmailsToDel);
       }
       public function setEdomainsToDEL($domainsarray){
            $this->DomainsToDel = $domainsarray;
       }
       public function setEMailsAdressesToDEL($emailarray){
            $this->EmailsToDel = $emailarray;
       }
       public function deleteEmailFromAdresses(){
            
       }
       public function deleteEmailFromHeadertags(){
        
       }
       public function get(){
            if(isset($this->MyOpenMailBox)){
                $fstruct = imap_fetchstructure();
            }
       }
       private function isSelectForDel($header){
            return $header->Deleted == 'D';
       }
       private function debugprint($array){
            print("<pre>");
            print_r($array);
            print("</pre>"); 
       }
       /**
        * MyImap::__destruct()
        * @return void
        */
       public function __destruct() {
            imap_close($this->MyOpenMailBox);
       }
       public function printHeader($header){
            print("<span> NR:".$header->Msgno."</span><span> ".(($this->isSelectForDel($header))?"DELETE":"")."</span><span> Mail:".$header->sender[0]->mailbox."@".$header->sender[0]->host."</span><br><span> Subject:".@$header->Subject."</span><br>");
       }
    }
?>
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan