Skip to content

I want to get all received emails except those emails which are received from '@global.com' domain? #181

@justcoding8

Description

@justcoding8

I want to get all the emails except those which are received from '@global.com' domain. How to exclude the emails received from 'xyz@global.com' and get all the emails ?

public function index(Request $request){ 
        //Artisan::call('email:parser'); 
        try {
            $oClient = new Client([
                'host' => env('IMAP_HOST', 'outlook.office365.com'),
                'port' => env('IMAP_PORT', 993),
                'encryption' => env('IMAP_ENCRYPTION', 'ssl'),
                'validate_cert' => env('IMAP_VALIDATE_CERT', true),
                'username' => env('IMAP_USERNAME', '****@**.com'),
                'password' => env('IMAP_PASSWORD', 'xyz'),          
            ]);

            $oClient->connect();
            $aFolder = $oClient->getFolder('ProcessedMails');
            $aMessage = $aFolder->getMessages();
            $PAGE_RECORDS = 5;
            $page = 1;           
        
                if (!empty($aMessage)) {
                    foreach ($aMessage as $oMessage) {
                        $MessageBody = $oMessage->getHTMLBody(TRUE);
                        
                        //$from = contains($MessageBody);
                        //$MessageBody = $oMessage->getHTMLBody(FALSE)->getFrom('xyz@global.com');
                     }
                }
           
           
        } catch (Exception $ex) {
            Log::error('Error << ' . $ex->getMessage());
            throw new \Exception($ex->getMessage(), $ex->getCode());
        }
   }
}

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions