PHP code example of laswitchtech / php-imap

1. Go to this page and download the library: Download laswitchtech/php-imap library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

laswitchtech / php-imap example snippets



//Import IMAP class into the global namespace
//These must be at the top of your script, not inside a function
use LaswitchTech\IMAP\phpIMAP;

//Load Composer's autoloader

$phpIMAP->config("level",5);

$phpIMAP->connect("[email protected]","*******************","imap.domain.com","993","ssl");

$phpIMAP->close();

$phpIMAP->login("[email protected]","*******************","imap.domain.com","993","ssl");

$phpIMAP->isConnected();

$phpIMAP->getUsername();

$phpIMAP->getHost();

$phpIMAP->getFolders();

$phpIMAP->setFolder("INBOX");

$phpIMAP->createFolder("New Folder");

$phpIMAP->deleteFolder("Old Folder");

foreach($phpIMAP->getMessages() as $message){}

$message->getTo();

$message->getReplyTo();

$message->getFrom();

$message->getSender();

$message->getCc();

$message->getBcc();

$message->getUid();

$message->getId();

$message->getSubject();

$message->getDate();

$message->getBody();

$message->read();

$message->unread();

$message->flag();

$message->unflag();

$message->draft();

$message->undraft();

$message->answer();

$message->unanswer();

$message->size();

$message->isRead();

$message->isFlagged();

$message->isRecent();

$message->isAnswered();

$message->isDraft();

$message->isDeleted();

$message->delete();

$message->copy("New Folder");

$message->move("New Folder");

$message->save();

foreach($message->getAttachments() as $attachment){}

$attachment->getDisposition();

$attachment->getEncoding();

$attachment->getId();

$attachment->getFilename();

$attachment->getFiletype();

$attachment->getContentType();

$attachment->getContent();

$attachment->save();