imap : Add Namespace for exceptions
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@5185 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
122
imap.php
122
imap.php
@@ -58,13 +58,13 @@ class imap
|
|||||||
$imapssl = false, $imapcertvalidate = true)
|
$imapssl = false, $imapcertvalidate = true)
|
||||||
{
|
{
|
||||||
if (! function_exists ("imap_open"))
|
if (! function_exists ("imap_open"))
|
||||||
throw new Exception ("PHP don't support IMAP. Please add it !", 500);
|
throw new \Exception ("PHP don't support IMAP. Please add it !", 500);
|
||||||
if (! function_exists ("mb_convert_encoding"))
|
if (! function_exists ("mb_convert_encoding"))
|
||||||
throw new Exception ("PHP don't support MBString. Please add it !", 500);
|
throw new \Exception ("PHP don't support MBString. Please add it !", 500);
|
||||||
if ($username === null)
|
if ($username === null)
|
||||||
throw new Exception ("No username provided for IMAP server", 500);
|
throw new \Exception ("No username provided for IMAP server", 500);
|
||||||
if ($password === null)
|
if ($password === null)
|
||||||
throw new Exception ("No password provided for IMAP server", 500);
|
throw new \Exception ("No password provided for IMAP server", 500);
|
||||||
$imapssl = ($imapssl !== false) ? "/ssl" : "";
|
$imapssl = ($imapssl !== false) ? "/ssl" : "";
|
||||||
$imapcertvalidate = ($imapcertvalidate === false) ? "/novalidate-cert" : "";
|
$imapcertvalidate = ($imapcertvalidate === false) ? "/novalidate-cert" : "";
|
||||||
$this->mailbox = "{"."$imapserver:$imapport/imap$imapssl$imapcertvalidate".
|
$this->mailbox = "{"."$imapserver:$imapport/imap$imapssl$imapcertvalidate".
|
||||||
@@ -79,16 +79,16 @@ class imap
|
|||||||
self::$instance[$this->mailbox] = @imap_open ($this->mailbox, $username,
|
self::$instance[$this->mailbox] = @imap_open ($this->mailbox, $username,
|
||||||
$password);
|
$password);
|
||||||
if (self::$instance[$this->mailbox] === FALSE)
|
if (self::$instance[$this->mailbox] === FALSE)
|
||||||
throw new Exception (imap_last_error());
|
throw new \Exception (imap_last_error());
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (\Exception $e)
|
||||||
{
|
{
|
||||||
// imap_errors() takes the errors and clear the error stack
|
// imap_errors() takes the errors and clear the error stack
|
||||||
$errors = imap_errors();
|
$errors = imap_errors();
|
||||||
if (substr ($e->getMessage (), 0, 35) ===
|
if (substr ($e->getMessage (), 0, 35) ===
|
||||||
"Can not authenticate to IMAP server")
|
"Can not authenticate to IMAP server")
|
||||||
throw new Exception ("IMAP error : ".$e->getMessage(), 401);
|
throw new \Exception ("IMAP error : ".$e->getMessage(), 401);
|
||||||
throw new Exception ("IMAP error : ".$e->getMessage(), 500);
|
throw new \Exception ("IMAP error : ".$e->getMessage(), 500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -103,7 +103,7 @@ class imap
|
|||||||
public function foldersList ()
|
public function foldersList ()
|
||||||
{
|
{
|
||||||
if ($this->mailbox === null)
|
if ($this->mailbox === null)
|
||||||
throw new Exception ("IMAP server not connected", 500);
|
throw new \Exception ("IMAP server not connected", 500);
|
||||||
$list = array_keys ($this->foldersListWithAttr ());
|
$list = array_keys ($this->foldersListWithAttr ());
|
||||||
sort ($list);
|
sort ($list);
|
||||||
return $list;
|
return $list;
|
||||||
@@ -115,7 +115,7 @@ class imap
|
|||||||
public function foldersListWithAttr ()
|
public function foldersListWithAttr ()
|
||||||
{
|
{
|
||||||
if ($this->mailbox === null)
|
if ($this->mailbox === null)
|
||||||
throw new Exception ("IMAP server not connected", 500);
|
throw new \Exception ("IMAP server not connected", 500);
|
||||||
$list = imap_getmailboxes (self::$instance[$this->mailbox], $this->mailbox,
|
$list = imap_getmailboxes (self::$instance[$this->mailbox], $this->mailbox,
|
||||||
"*");
|
"*");
|
||||||
$res = array ();
|
$res = array ();
|
||||||
@@ -137,16 +137,16 @@ class imap
|
|||||||
public function changeFolder ($folder)
|
public function changeFolder ($folder)
|
||||||
{
|
{
|
||||||
if ($this->mailbox === null)
|
if ($this->mailbox === null)
|
||||||
throw new Exception ("IMAP server not connected", 500);
|
throw new \Exception ("IMAP server not connected", 500);
|
||||||
if (! in_array ($folder, $this->foldersList ()))
|
if (! in_array ($folder, $this->foldersList ()))
|
||||||
throw new Exception ("Folder not found", 404);
|
throw new \Exception ("Folder not found", 404);
|
||||||
$folderUTF7 = mb_convert_encoding ($folder, "UTF7-IMAP","UTF-8");
|
$folderUTF7 = mb_convert_encoding ($folder, "UTF7-IMAP","UTF-8");
|
||||||
$rc = @imap_reopen (self::$instance[$this->mailbox],
|
$rc = @imap_reopen (self::$instance[$this->mailbox],
|
||||||
$this->mailbox.$folderUTF7);
|
$this->mailbox.$folderUTF7);
|
||||||
if ($rc === true)
|
if ($rc === true)
|
||||||
$this->curDir = $folder;
|
$this->curDir = $folder;
|
||||||
else
|
else
|
||||||
throw new Exception ("Can't go in provided folder", 500);
|
throw new \Exception ("Can't go in provided folder", 500);
|
||||||
return $rc;
|
return $rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,7 +155,7 @@ class imap
|
|||||||
public function getFolder ()
|
public function getFolder ()
|
||||||
{
|
{
|
||||||
if ($this->mailbox === null)
|
if ($this->mailbox === null)
|
||||||
throw new Exception ("IMAP server not connected", 500);
|
throw new \Exception ("IMAP server not connected", 500);
|
||||||
return $this->curDir;
|
return $this->curDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,9 +165,9 @@ class imap
|
|||||||
public function createFolder ($folder)
|
public function createFolder ($folder)
|
||||||
{
|
{
|
||||||
if ($this->mailbox === null)
|
if ($this->mailbox === null)
|
||||||
throw new Exception ("IMAP server not connected", 500);
|
throw new \Exception ("IMAP server not connected", 500);
|
||||||
if ( in_array ($folder, $this->foldersList ()))
|
if ( in_array ($folder, $this->foldersList ()))
|
||||||
throw new Exception ("Folder already exists", 406);
|
throw new \Exception ("Folder already exists", 406);
|
||||||
$folderUTF7 = mb_convert_encoding ($folder, "UTF7-IMAP","UTF-8");
|
$folderUTF7 = mb_convert_encoding ($folder, "UTF7-IMAP","UTF-8");
|
||||||
return imap_createmailbox (self::$instance[$this->mailbox],
|
return imap_createmailbox (self::$instance[$this->mailbox],
|
||||||
$this->mailbox.$folderUTF7);
|
$this->mailbox.$folderUTF7);
|
||||||
@@ -179,9 +179,9 @@ class imap
|
|||||||
public function deleteFolder ($folder)
|
public function deleteFolder ($folder)
|
||||||
{
|
{
|
||||||
if ($this->mailbox === null)
|
if ($this->mailbox === null)
|
||||||
throw new Exception ("IMAP server not connected", 500);
|
throw new \Exception ("IMAP server not connected", 500);
|
||||||
if (! in_array ($folder, $this->foldersList ()))
|
if (! in_array ($folder, $this->foldersList ()))
|
||||||
throw new Exception ("Folder not found", 404);
|
throw new \Exception ("Folder not found", 404);
|
||||||
$folderUTF7 = mb_convert_encoding ($folder, "UTF7-IMAP","UTF-8");
|
$folderUTF7 = mb_convert_encoding ($folder, "UTF7-IMAP","UTF-8");
|
||||||
return imap_deletemailbox (self::$instance[$this->mailbox],
|
return imap_deletemailbox (self::$instance[$this->mailbox],
|
||||||
$this->mailbox.$folderUTF7);
|
$this->mailbox.$folderUTF7);
|
||||||
@@ -193,7 +193,7 @@ class imap
|
|||||||
public function getSubscribe ()
|
public function getSubscribe ()
|
||||||
{
|
{
|
||||||
if ($this->mailbox === null)
|
if ($this->mailbox === null)
|
||||||
throw new Exception ("IMAP server not connected", 500);
|
throw new \Exception ("IMAP server not connected", 500);
|
||||||
$subs = imap_getsubscribed (self::$instance[$this->mailbox], $this->mailbox,
|
$subs = imap_getsubscribed (self::$instance[$this->mailbox], $this->mailbox,
|
||||||
"*");
|
"*");
|
||||||
$res = array ();
|
$res = array ();
|
||||||
@@ -216,7 +216,7 @@ class imap
|
|||||||
public function addSubscribe ($folder)
|
public function addSubscribe ($folder)
|
||||||
{
|
{
|
||||||
if ($this->mailbox === null)
|
if ($this->mailbox === null)
|
||||||
throw new Exception ("IMAP server not connected", 500);
|
throw new \Exception ("IMAP server not connected", 500);
|
||||||
$folderUTF7 = mb_convert_encoding ($folder, "UTF7-IMAP","UTF-8");
|
$folderUTF7 = mb_convert_encoding ($folder, "UTF7-IMAP","UTF-8");
|
||||||
return imap_subscribe (self::$instance[$this->mailbox],
|
return imap_subscribe (self::$instance[$this->mailbox],
|
||||||
$this->mailbox.$folder);
|
$this->mailbox.$folder);
|
||||||
@@ -229,7 +229,7 @@ class imap
|
|||||||
public function delSubscribe ($folder)
|
public function delSubscribe ($folder)
|
||||||
{
|
{
|
||||||
if ($this->mailbox === null)
|
if ($this->mailbox === null)
|
||||||
throw new Exception ("IMAP server not connected", 500);
|
throw new \Exception ("IMAP server not connected", 500);
|
||||||
$folderUTF7 = mb_convert_encoding ($folder, "UTF7-IMAP","UTF-8");
|
$folderUTF7 = mb_convert_encoding ($folder, "UTF7-IMAP","UTF-8");
|
||||||
return imap_unsubscribe (self::$instance[$this->mailbox],
|
return imap_unsubscribe (self::$instance[$this->mailbox],
|
||||||
$this->mailbox.$folder);
|
$this->mailbox.$folder);
|
||||||
@@ -250,13 +250,13 @@ class imap
|
|||||||
public function getFolderInfo ($folder)
|
public function getFolderInfo ($folder)
|
||||||
{
|
{
|
||||||
if ($this->mailbox === null)
|
if ($this->mailbox === null)
|
||||||
throw new Exception ("IMAP server not connected", 500);
|
throw new \Exception ("IMAP server not connected", 500);
|
||||||
$oldFolder = $this->curDir;
|
$oldFolder = $this->curDir;
|
||||||
$this->changeFolder ($folder);
|
$this->changeFolder ($folder);
|
||||||
$rc = imap_mailboxmsginfo (self::$instance[$this->mailbox]);
|
$rc = imap_mailboxmsginfo (self::$instance[$this->mailbox]);
|
||||||
$this->changeFolder ($oldFolder);
|
$this->changeFolder ($oldFolder);
|
||||||
if ($rc === false)
|
if ($rc === false)
|
||||||
throw new Exception ("Can't read information for folder $folder", 500);
|
throw new \Exception ("Can't read information for folder $folder", 500);
|
||||||
return $rc;
|
return $rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -271,7 +271,7 @@ class imap
|
|||||||
public function imapSortMail ($mailHeaders, $field, $orderAsc = TRUE)
|
public function imapSortMail ($mailHeaders, $field, $orderAsc = TRUE)
|
||||||
{
|
{
|
||||||
if ($this->mailbox === null)
|
if ($this->mailbox === null)
|
||||||
throw new Exception ("IMAP server not connected", 500);
|
throw new \Exception ("IMAP server not connected", 500);
|
||||||
$this->changeFolder ($this->curDir);
|
$this->changeFolder ($this->curDir);
|
||||||
$sortList = array ();
|
$sortList = array ();
|
||||||
$sortInc = array ();
|
$sortInc = array ();
|
||||||
@@ -304,7 +304,7 @@ class imap
|
|||||||
public function mailsDate ($from = 1, $nbmails = 30)
|
public function mailsDate ($from = 1, $nbmails = 30)
|
||||||
{
|
{
|
||||||
if ($this->mailbox === null)
|
if ($this->mailbox === null)
|
||||||
throw new Exception ("IMAP server not connected", 500);
|
throw new \Exception ("IMAP server not connected", 500);
|
||||||
$this->changeFolder ($this->curDir);
|
$this->changeFolder ($this->curDir);
|
||||||
if ($from === null)
|
if ($from === null)
|
||||||
$from = 1;
|
$from = 1;
|
||||||
@@ -319,7 +319,7 @@ class imap
|
|||||||
if ($from < 1)
|
if ($from < 1)
|
||||||
$from = 1;
|
$from = 1;
|
||||||
if ($from > $MC->Nmsgs)
|
if ($from > $MC->Nmsgs)
|
||||||
throw new Exception ("Mail start is higher than the number of mails",
|
throw new \Exception ("Mail start is higher than the number of mails",
|
||||||
500);
|
500);
|
||||||
$from = $MC->Nmsgs - $from + 1;
|
$from = $MC->Nmsgs - $from + 1;
|
||||||
$to = $from + $nbmails - 1;
|
$to = $from + $nbmails - 1;
|
||||||
@@ -329,7 +329,7 @@ class imap
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ($from > $MC->Nmsgs)
|
if ($from > $MC->Nmsgs)
|
||||||
throw new Exception ("Mail start is higher than the number of mails",
|
throw new \Exception ("Mail start is higher than the number of mails",
|
||||||
500);
|
500);
|
||||||
if ($from < 1)
|
if ($from < 1)
|
||||||
$from = 1;
|
$from = 1;
|
||||||
@@ -352,7 +352,7 @@ class imap
|
|||||||
public function mailsThread ()
|
public function mailsThread ()
|
||||||
{
|
{
|
||||||
if ($this->mailbox === null)
|
if ($this->mailbox === null)
|
||||||
throw new Exception ("IMAP server not connected", 500);
|
throw new \Exception ("IMAP server not connected", 500);
|
||||||
$this->changeFolder ($this->curDir);
|
$this->changeFolder ($this->curDir);
|
||||||
$threads = @imap_thread (self::$instance[$this->mailbox]);
|
$threads = @imap_thread (self::$instance[$this->mailbox]);
|
||||||
// imap_errors() takes the errors and clear the error stack
|
// imap_errors() takes the errors and clear the error stack
|
||||||
@@ -383,7 +383,7 @@ class imap
|
|||||||
public function mailsNumber ()
|
public function mailsNumber ()
|
||||||
{
|
{
|
||||||
if ($this->mailbox === null)
|
if ($this->mailbox === null)
|
||||||
throw new Exception ("IMAP server not connected", 500);
|
throw new \Exception ("IMAP server not connected", 500);
|
||||||
$this->changeFolder ($this->curDir);
|
$this->changeFolder ($this->curDir);
|
||||||
$MC = imap_check (self::$instance[$this->mailbox]);
|
$MC = imap_check (self::$instance[$this->mailbox]);
|
||||||
return $MC->Nmsgs;
|
return $MC->Nmsgs;
|
||||||
@@ -395,7 +395,7 @@ class imap
|
|||||||
public function mailsSearch ($criteria)
|
public function mailsSearch ($criteria)
|
||||||
{
|
{
|
||||||
if ($this->mailbox === null)
|
if ($this->mailbox === null)
|
||||||
throw new Exception ("IMAP server not connected", 500);
|
throw new \Exception ("IMAP server not connected", 500);
|
||||||
$this->changeFolder ($this->curDir);
|
$this->changeFolder ($this->curDir);
|
||||||
return imap_search (self::$instance[$this->mailbox], $criteria);
|
return imap_search (self::$instance[$this->mailbox], $criteria);
|
||||||
}
|
}
|
||||||
@@ -409,7 +409,7 @@ class imap
|
|||||||
public function mailMove ($msgno, $folder)
|
public function mailMove ($msgno, $folder)
|
||||||
{
|
{
|
||||||
if ($this->mailbox === null)
|
if ($this->mailbox === null)
|
||||||
throw new Exception ("IMAP server not connected", 500);
|
throw new \Exception ("IMAP server not connected", 500);
|
||||||
$this->changeFolder ($this->curDir);
|
$this->changeFolder ($this->curDir);
|
||||||
if (is_array ($msgno))
|
if (is_array ($msgno))
|
||||||
$msgno = implode (",", $msgno);
|
$msgno = implode (",", $msgno);
|
||||||
@@ -432,7 +432,7 @@ class imap
|
|||||||
public function mailCopy ($msgno, $folder)
|
public function mailCopy ($msgno, $folder)
|
||||||
{
|
{
|
||||||
if ($this->mailbox === null)
|
if ($this->mailbox === null)
|
||||||
throw new Exception ("IMAP server not connected", 500);
|
throw new \Exception ("IMAP server not connected", 500);
|
||||||
$this->changeFolder ($this->curDir);
|
$this->changeFolder ($this->curDir);
|
||||||
if (is_array ($msgno))
|
if (is_array ($msgno))
|
||||||
$msgno = implode (",", $msgno);
|
$msgno = implode (",", $msgno);
|
||||||
@@ -451,7 +451,7 @@ class imap
|
|||||||
public function expunge ()
|
public function expunge ()
|
||||||
{
|
{
|
||||||
if ($this->mailbox === null)
|
if ($this->mailbox === null)
|
||||||
throw new Exception ("IMAP server not connected", 500);
|
throw new \Exception ("IMAP server not connected", 500);
|
||||||
$this->changeFolder ($this->curDir);
|
$this->changeFolder ($this->curDir);
|
||||||
return imap_expunge (self::$instance[$this->mailbox]);
|
return imap_expunge (self::$instance[$this->mailbox]);
|
||||||
}
|
}
|
||||||
@@ -465,7 +465,7 @@ class imap
|
|||||||
public function getEmailRaw ($msgno)
|
public function getEmailRaw ($msgno)
|
||||||
{
|
{
|
||||||
if ($this->mailbox === null)
|
if ($this->mailbox === null)
|
||||||
throw new Exception ("IMAP server not connected", 500);
|
throw new \Exception ("IMAP server not connected", 500);
|
||||||
$this->changeFolder ($this->curDir);
|
$this->changeFolder ($this->curDir);
|
||||||
// Clear the errors
|
// Clear the errors
|
||||||
imap_errors();
|
imap_errors();
|
||||||
@@ -473,7 +473,7 @@ class imap
|
|||||||
@imap_body (self::$instance[$this->mailbox], $msgno);
|
@imap_body (self::$instance[$this->mailbox], $msgno);
|
||||||
$errors = imap_errors ();
|
$errors = imap_errors ();
|
||||||
if ($errors !== false)
|
if ($errors !== false)
|
||||||
throw new Exception ("Mail not found", 404);
|
throw new \Exception ("Mail not found", 404);
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -483,14 +483,14 @@ class imap
|
|||||||
public function getEmailHeadersRaw ($msgno)
|
public function getEmailHeadersRaw ($msgno)
|
||||||
{
|
{
|
||||||
if ($this->mailbox === null)
|
if ($this->mailbox === null)
|
||||||
throw new Exception ("IMAP server not connected", 500);
|
throw new \Exception ("IMAP server not connected", 500);
|
||||||
$this->changeFolder ($this->curDir);
|
$this->changeFolder ($this->curDir);
|
||||||
// Clear the errors
|
// Clear the errors
|
||||||
imap_errors();
|
imap_errors();
|
||||||
$content = @imap_fetchheader (self::$instance[$this->mailbox], $msgno);
|
$content = @imap_fetchheader (self::$instance[$this->mailbox], $msgno);
|
||||||
$errors = imap_errors ();
|
$errors = imap_errors ();
|
||||||
if ($errors !== false)
|
if ($errors !== false)
|
||||||
throw new Exception ("Mail not found", 404);
|
throw new \Exception ("Mail not found", 404);
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -500,14 +500,14 @@ class imap
|
|||||||
public function getEmailBodyRaw ($msgno)
|
public function getEmailBodyRaw ($msgno)
|
||||||
{
|
{
|
||||||
if ($this->mailbox === null)
|
if ($this->mailbox === null)
|
||||||
throw new Exception ("IMAP server not connected", 500);
|
throw new \Exception ("IMAP server not connected", 500);
|
||||||
$this->changeFolder ($this->curDir);
|
$this->changeFolder ($this->curDir);
|
||||||
// Clear the errors
|
// Clear the errors
|
||||||
imap_errors();
|
imap_errors();
|
||||||
$content = @imap_body (self::$instance[$this->mailbox], $msgno);
|
$content = @imap_body (self::$instance[$this->mailbox], $msgno);
|
||||||
$errors = imap_errors ();
|
$errors = imap_errors ();
|
||||||
if ($errors !== false)
|
if ($errors !== false)
|
||||||
throw new Exception ("Mail not found", 404);
|
throw new \Exception ("Mail not found", 404);
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -517,14 +517,14 @@ class imap
|
|||||||
public function getStructure ($msgno)
|
public function getStructure ($msgno)
|
||||||
{
|
{
|
||||||
if ($this->mailbox === null)
|
if ($this->mailbox === null)
|
||||||
throw new Exception ("IMAP server not connected", 500);
|
throw new \Exception ("IMAP server not connected", 500);
|
||||||
$this->changeFolder ($this->curDir);
|
$this->changeFolder ($this->curDir);
|
||||||
// Clear the errors
|
// Clear the errors
|
||||||
imap_errors();
|
imap_errors();
|
||||||
$structure = @imap_fetchstructure (self::$instance[$this->mailbox], $msgno);
|
$structure = @imap_fetchstructure (self::$instance[$this->mailbox], $msgno);
|
||||||
$errors = imap_errors ();
|
$errors = imap_errors ();
|
||||||
if ($errors !== false)
|
if ($errors !== false)
|
||||||
throw new Exception ("Mail not found", 404);
|
throw new \Exception ("Mail not found", 404);
|
||||||
return $structure;
|
return $structure;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -534,14 +534,14 @@ class imap
|
|||||||
public function getStructureWithContent ($msgno)
|
public function getStructureWithContent ($msgno)
|
||||||
{
|
{
|
||||||
if ($this->mailbox === null)
|
if ($this->mailbox === null)
|
||||||
throw new Exception ("IMAP server not connected", 500);
|
throw new \Exception ("IMAP server not connected", 500);
|
||||||
$this->changeFolder ($this->curDir);
|
$this->changeFolder ($this->curDir);
|
||||||
// Clear the errors
|
// Clear the errors
|
||||||
imap_errors();
|
imap_errors();
|
||||||
$structure = @imap_fetchstructure (self::$instance[$this->mailbox], $msgno);
|
$structure = @imap_fetchstructure (self::$instance[$this->mailbox], $msgno);
|
||||||
$errors = imap_errors ();
|
$errors = imap_errors ();
|
||||||
if ($errors !== false)
|
if ($errors !== false)
|
||||||
throw new Exception ("Mail not found", 404);
|
throw new \Exception ("Mail not found", 404);
|
||||||
if (! isset ($structure->parts))
|
if (! isset ($structure->parts))
|
||||||
{
|
{
|
||||||
// In case of PLAIN text, there is no parts
|
// In case of PLAIN text, there is no parts
|
||||||
@@ -602,7 +602,7 @@ class imap
|
|||||||
$structure->parts[$part1]->parts[$part2]->mimetype = "other/".
|
$structure->parts[$part1]->parts[$part2]->mimetype = "other/".
|
||||||
strtolower ($struct2->subtype);
|
strtolower ($struct2->subtype);
|
||||||
else
|
else
|
||||||
throw new Exception (sprintf (
|
throw new \Exception (sprintf (
|
||||||
dgettext("domframework",
|
dgettext("domframework",
|
||||||
"Unknown type in imap_fetchstructure : %s"),
|
"Unknown type in imap_fetchstructure : %s"),
|
||||||
$struct2->type), 500);
|
$struct2->type), 500);
|
||||||
@@ -648,7 +648,7 @@ class imap
|
|||||||
$structure->parts[$part1]->mimetype = "other/".
|
$structure->parts[$part1]->mimetype = "other/".
|
||||||
strtolower ($struct1->subtype);
|
strtolower ($struct1->subtype);
|
||||||
else
|
else
|
||||||
throw new Exception (sprintf (
|
throw new \Exception (sprintf (
|
||||||
dgettext("domframework",
|
dgettext("domframework",
|
||||||
"Unknown type in imap_fetchstructure : %s"),
|
"Unknown type in imap_fetchstructure : %s"),
|
||||||
$struct1->type), 500);
|
$struct1->type), 500);
|
||||||
@@ -667,11 +667,11 @@ class imap
|
|||||||
public function getStructureContent ($msgno, $part)
|
public function getStructureContent ($msgno, $part)
|
||||||
{
|
{
|
||||||
if ($this->mailbox === null)
|
if ($this->mailbox === null)
|
||||||
throw new Exception ("IMAP server not connected", 500);
|
throw new \Exception ("IMAP server not connected", 500);
|
||||||
$structure = $this->getStructureWithContent ($msgno);
|
$structure = $this->getStructureWithContent ($msgno);
|
||||||
if (isset ($structure->parts[$part]))
|
if (isset ($structure->parts[$part]))
|
||||||
return $structure->parts[$part];
|
return $structure->parts[$part];
|
||||||
throw new Exception ("Part not found in the mail", 404);
|
throw new \Exception ("Part not found in the mail", 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return the part identifiers of the structure of the mail body. To be used
|
/** Return the part identifiers of the structure of the mail body. To be used
|
||||||
@@ -681,7 +681,7 @@ class imap
|
|||||||
public function getStructureParts ($msgno)
|
public function getStructureParts ($msgno)
|
||||||
{
|
{
|
||||||
if ($this->mailbox === null)
|
if ($this->mailbox === null)
|
||||||
throw new Exception ("IMAP server not connected", 500);
|
throw new \Exception ("IMAP server not connected", 500);
|
||||||
$structure = $this->getStructure ($msgno);
|
$structure = $this->getStructure ($msgno);
|
||||||
if (! isset ($structure->parts))
|
if (! isset ($structure->parts))
|
||||||
return array ();
|
return array ();
|
||||||
@@ -697,14 +697,14 @@ class imap
|
|||||||
public function mailsDel ($msgno)
|
public function mailsDel ($msgno)
|
||||||
{
|
{
|
||||||
if ($this->mailbox === null)
|
if ($this->mailbox === null)
|
||||||
throw new Exception ("IMAP server not connected", 500);
|
throw new \Exception ("IMAP server not connected", 500);
|
||||||
$this->changeFolder ($this->curDir);
|
$this->changeFolder ($this->curDir);
|
||||||
if (is_array ($msgno))
|
if (is_array ($msgno))
|
||||||
$msgno = implode (",", $msgno);
|
$msgno = implode (",", $msgno);
|
||||||
$rc = @imap_delete (self::$instance[$this->mailbox], $msgno);
|
$rc = @imap_delete (self::$instance[$this->mailbox], $msgno);
|
||||||
imap_errors();
|
imap_errors();
|
||||||
if ($rc === FALSE)
|
if ($rc === FALSE)
|
||||||
throw new Exception ("No mailID provided can be found : ABORT");
|
throw new \Exception ("No mailID provided can be found : ABORT");
|
||||||
if ($this->autoexpunge)
|
if ($this->autoexpunge)
|
||||||
return imap_expunge(self::$instance[$this->mailbox]);
|
return imap_expunge(self::$instance[$this->mailbox]);
|
||||||
return $rc;
|
return $rc;
|
||||||
@@ -718,14 +718,14 @@ class imap
|
|||||||
public function mailAdd ($content)
|
public function mailAdd ($content)
|
||||||
{
|
{
|
||||||
if ($this->mailbox === null)
|
if ($this->mailbox === null)
|
||||||
throw new Exception ("IMAP server not connected", 500);
|
throw new \Exception ("IMAP server not connected", 500);
|
||||||
$folderUTF7 = mb_convert_encoding ($this->curDir, "UTF7-IMAP","UTF-8");
|
$folderUTF7 = mb_convert_encoding ($this->curDir, "UTF7-IMAP","UTF-8");
|
||||||
$rc = imap_append (self::$instance[$this->mailbox],
|
$rc = imap_append (self::$instance[$this->mailbox],
|
||||||
$this->mailbox.$folderUTF7,
|
$this->mailbox.$folderUTF7,
|
||||||
$content);
|
$content);
|
||||||
$errors = imap_errors();
|
$errors = imap_errors();
|
||||||
if ($rc === FALSE)
|
if ($rc === FALSE)
|
||||||
throw new Exception ("Error when saving the mail in folder : ".
|
throw new \Exception ("Error when saving the mail in folder : ".
|
||||||
implode (" ", $errors), 500);
|
implode (" ", $errors), 500);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -738,7 +738,7 @@ class imap
|
|||||||
public function getQuota ()
|
public function getQuota ()
|
||||||
{
|
{
|
||||||
if ($this->mailbox === null)
|
if ($this->mailbox === null)
|
||||||
throw new Exception ("IMAP server not connected", 500);
|
throw new \Exception ("IMAP server not connected", 500);
|
||||||
$quota = @imap_get_quotaroot (self::$instance[$this->mailbox], "INBOX");
|
$quota = @imap_get_quotaroot (self::$instance[$this->mailbox], "INBOX");
|
||||||
imap_errors();
|
imap_errors();
|
||||||
if (! isset ($quota["STORAGE"]))
|
if (! isset ($quota["STORAGE"]))
|
||||||
@@ -765,7 +765,7 @@ class imap
|
|||||||
public function setFlag ($msgno, $flags)
|
public function setFlag ($msgno, $flags)
|
||||||
{
|
{
|
||||||
if ($this->mailbox === null)
|
if ($this->mailbox === null)
|
||||||
throw new Exception ("IMAP server not connected", 500);
|
throw new \Exception ("IMAP server not connected", 500);
|
||||||
$this->changeFolder ($this->curDir);
|
$this->changeFolder ($this->curDir);
|
||||||
if (is_array ($msgno))
|
if (is_array ($msgno))
|
||||||
$msgno = implode (",", $msgno);
|
$msgno = implode (",", $msgno);
|
||||||
@@ -773,7 +773,7 @@ class imap
|
|||||||
implode (" ", $flags));
|
implode (" ", $flags));
|
||||||
imap_errors();
|
imap_errors();
|
||||||
if ($rc === FALSE)
|
if ($rc === FALSE)
|
||||||
throw new Exception ("Can't define the flags", 500);
|
throw new \Exception ("Can't define the flags", 500);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -792,7 +792,7 @@ class imap
|
|||||||
public function unsetFlag ($msgno, $flags)
|
public function unsetFlag ($msgno, $flags)
|
||||||
{
|
{
|
||||||
if ($this->mailbox === null)
|
if ($this->mailbox === null)
|
||||||
throw new Exception ("IMAP server not connected", 500);
|
throw new \Exception ("IMAP server not connected", 500);
|
||||||
$this->changeFolder ($this->curDir);
|
$this->changeFolder ($this->curDir);
|
||||||
if (is_array ($msgno))
|
if (is_array ($msgno))
|
||||||
$msgno = implode (",", $msgno);
|
$msgno = implode (",", $msgno);
|
||||||
@@ -800,7 +800,7 @@ class imap
|
|||||||
implode (" ", $flags));
|
implode (" ", $flags));
|
||||||
imap_errors();
|
imap_errors();
|
||||||
if ($rc === FALSE)
|
if ($rc === FALSE)
|
||||||
throw new Exception ("Can't define the flags", 500);
|
throw new \Exception ("Can't define the flags", 500);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -812,7 +812,7 @@ class imap
|
|||||||
public function markMailAsRead ($msgno)
|
public function markMailAsRead ($msgno)
|
||||||
{
|
{
|
||||||
if ($this->mailbox === null)
|
if ($this->mailbox === null)
|
||||||
throw new Exception ("IMAP server not connected", 500);
|
throw new \Exception ("IMAP server not connected", 500);
|
||||||
$this->changeFolder ($this->curDir);
|
$this->changeFolder ($this->curDir);
|
||||||
if (is_array ($msgno))
|
if (is_array ($msgno))
|
||||||
$msgno = implode (",", $msgno);
|
$msgno = implode (",", $msgno);
|
||||||
@@ -820,7 +820,7 @@ class imap
|
|||||||
"\\Seen");
|
"\\Seen");
|
||||||
imap_errors();
|
imap_errors();
|
||||||
if ($rc === FALSE)
|
if ($rc === FALSE)
|
||||||
throw new Exception ("Can't mark mail as read", 500);
|
throw new \Exception ("Can't mark mail as read", 500);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -832,7 +832,7 @@ class imap
|
|||||||
public function markMailAsUnread ($msgno)
|
public function markMailAsUnread ($msgno)
|
||||||
{
|
{
|
||||||
if ($this->mailbox === null)
|
if ($this->mailbox === null)
|
||||||
throw new Exception ("IMAP server not connected", 500);
|
throw new \Exception ("IMAP server not connected", 500);
|
||||||
$this->changeFolder ($this->curDir);
|
$this->changeFolder ($this->curDir);
|
||||||
if (is_array ($msgno))
|
if (is_array ($msgno))
|
||||||
$msgno = implode (",", $msgno);
|
$msgno = implode (",", $msgno);
|
||||||
@@ -840,7 +840,7 @@ class imap
|
|||||||
"\\Seen");
|
"\\Seen");
|
||||||
imap_errors();
|
imap_errors();
|
||||||
if ($rc === FALSE)
|
if ($rc === FALSE)
|
||||||
throw new Exception ("Can't mark mail as read", 500);
|
throw new \Exception ("Can't mark mail as read", 500);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user