Last active
February 10, 2020 13:47
-
-
Save lucasaba/e2289aa8b423f2adf448562557ff5709 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @param Mailbox $mailbox | |
* @return PecServer | |
*/ | |
private function getServer(Mailbox $mailbox) | |
{ | |
$server = new PecServer($mailbox->getHost(), $mailbox->getPort()); | |
$server->setAuthentication($mailbox->getUsername(), $mailbox->getPassword()); | |
return $server; | |
} | |
private function spostaMessaggioInCartella($msg_uid, $nomeCartella, Mailbox $mailbox) | |
{ | |
$nomeCartellaInCuiSpostare = $mailbox->getMailbox().".$nomeCartella"; | |
try { | |
$server = $this->getServer($mailbox); | |
if (! $server->hasMailBox($nomeCartellaInCuiSpostare)) { | |
$server->createMailBox($nomeCartellaInCuiSpostare); | |
} | |
$inboxMsg = $server->getMessageByUid($msg_uid); | |
if ($inboxMsg === false || $inboxMsg->moveToMailBox($nomeCartellaInCuiSpostare) === false) { | |
return false; | |
} | |
} catch (\RuntimeException $runtimeException) { | |
return null; | |
} | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment