1. Go to this page and download the library: Download laikait/laika-mailman 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/ */
$mailer->xmailer('My App 2.0'); // X-Mailer: My App 2.0
$mailer->xmailer(Mailer::XMAILER_NONE); // no X-Mailer header at all
$mailer->xmailer(Mailer::XMAILER_PHPMAILER); // PHPMailer's default, version and all
use Laika\Mailman\Reader\Pop3Reader;
$reader = new Pop3Reader([
'host' => 'pop.gmail.com',
'port' => 995,
'encryption' => 'ssl',
'username' => '[email protected]',
'password' => 'app-password',
]);
$reader->connect();
echo $reader->count(), " messages\n";
// TOP n 0 — headers only, far cheaper than RETR for building a listing
foreach (array_keys($reader->listing()) as $number) {
echo $reader->headers($number)->subject, "\n";
}
$message = $reader->fetch(1); // full RETR
$reader->disconnect();
$message->subject; // string, decoded
$message->from; // ['email' => ..., 'name' => ...]
$message->to; // list of the same
$message->date; // ?DateTimeImmutable
$message->textBody; // text/plain part
$message->htmlBody; // text/html part
$message->body(); // htmlBody if present, else textBody
$message->attachments; // Attachment[], including inline cid: parts
$message->files(); // Attachment[], excluding inline parts
$message->flags; // IMAP only
$message->header('x-spam-score');
$pipeline->extract('customer', '/\bCUST-(\d{4,})/i')
->extract('ticket', '/\bSUP-(\d+)/i', [Extractor::SUBJECT]); // replaces the preset
$r->first('ticket'); // '5150' — best available
$r->all('ticket'); // ['5150', '991', '1234'] — every hit, best first
$r->confidenceOf('ticket'); // 'header'
$r->isTrusted('ticket'); // true for header/recipient only
->otherwise(function (ScanResult $r) use ($tickets) {
if ($r->isReply() && $t = $tickets->findByMessageIds($r->threadIds)) {
return $t->appendReply($r->message);
}
$tickets->open($r->message);
})