2019-12-13 18:09:05 +00:00
|
|
|
<?php
|
2019-12-13 19:10:45 +00:00
|
|
|
error_reporting(E_ERROR | E_PARSE);
|
2022-05-19 08:47:30 +00:00
|
|
|
require_once(__DIR__ . '/vendor/autoload.php');
|
|
|
|
require_once(__DIR__ . '/config.php');
|
2022-05-17 08:52:56 +00:00
|
|
|
|
|
|
|
use Mail2Deck\MailClass;
|
|
|
|
use Mail2Deck\DeckClass;
|
|
|
|
use Mail2Deck\ConvertToMD;
|
2025-02-12 15:38:17 +00:00
|
|
|
use Mail2Deck\AttachmentClass;
|
|
|
|
use Mail2Deck\CreateCardClass;
|
2019-12-13 18:09:05 +00:00
|
|
|
|
2022-02-04 08:46:44 +00:00
|
|
|
$inbox = new MailClass();
|
|
|
|
$emails = $inbox->getNewMessages();
|
2019-12-13 18:09:05 +00:00
|
|
|
|
2022-05-19 08:16:03 +00:00
|
|
|
if(!$emails) {
|
|
|
|
// delete all messages marked for deletion and return
|
|
|
|
$inbox->expunge();
|
|
|
|
return;
|
|
|
|
}
|
2022-05-17 08:52:56 +00:00
|
|
|
|
|
|
|
for ($j = 0; $j < count($emails) && $j < 5; $j++) {
|
|
|
|
$structure = $inbox->fetchMessageStructure($emails[$j]);
|
|
|
|
$base64encode = false;
|
|
|
|
if($structure->encoding == 3) {
|
|
|
|
$base64encode = true; // BASE64
|
|
|
|
}
|
2019-12-13 18:22:40 +00:00
|
|
|
|
2025-02-12 15:38:17 +00:00
|
|
|
//Check for attachment
|
|
|
|
$attclass= new AttachmentClass();
|
|
|
|
$attNames = $attclass->Attachment($structure,$inbox, $emails[$j]);
|
2022-05-17 08:52:56 +00:00
|
|
|
$overview = $inbox->headerInfo($emails[$j]);
|
2022-04-13 10:31:54 +00:00
|
|
|
|
2025-02-12 15:38:17 +00:00
|
|
|
//Create Card
|
|
|
|
$createCardClass= new CreateCardClass();
|
|
|
|
$board = $createCardClass->extractBoardName($overview);
|
2025-01-16 12:12:47 +00:00
|
|
|
|
2022-05-17 08:52:56 +00:00
|
|
|
$mailSender = new stdClass();
|
2025-02-12 15:38:17 +00:00
|
|
|
$data = $createCardClass->createMailData($overview, $mailSender);
|
2025-02-20 16:21:32 +00:00
|
|
|
$body = $createCardClass->fetchMailBody($structure,$inbox, $emails[$j]);
|
2019-12-13 18:22:40 +00:00
|
|
|
|
2022-05-17 08:52:56 +00:00
|
|
|
$newcard = new DeckClass();
|
2025-02-12 15:38:17 +00:00
|
|
|
$data->attachments = $attNames;
|
|
|
|
$data->description = $createCardClass->mailDescription($body, $base64encode, $attNames);
|
2025-01-16 12:12:47 +00:00
|
|
|
|
2025-02-12 15:38:17 +00:00
|
|
|
$mailSender->userId = $overview->reply_to[0]->mailbox;
|
|
|
|
$mailSender->host = $overview->reply_to[0]->host;
|
2025-01-16 12:12:47 +00:00
|
|
|
|
2025-02-12 15:38:17 +00:00
|
|
|
$cleanedSubject = $createCardClass->cleanedSubject($data->title, $data->description, $newcard);
|
|
|
|
$createCardClass->createCard($newcard, $data, $mailSender, $cleanedSubject, $inbox);
|
2022-05-17 08:52:56 +00:00
|
|
|
|
|
|
|
//remove email after processing
|
|
|
|
if(DELETE_MAIL_AFTER_PROCESSING) {
|
|
|
|
$inbox->delete($emails[$j]);
|
|
|
|
}
|
|
|
|
}
|
2021-12-31 00:29:25 +00:00
|
|
|
?>
|