Integrated IMAP Webmail.
More...
|
| deleteMessage ($imap, $folder, $uid) |
| Delete a message. Requires imap handle, folder and uid of the mail to delete. More...
|
|
| drawFolders ($imap, $folders) |
| Draw a list with all folders of this mailbox. More...
|
|
| drawHeaders ($emails, $currentFolder, $lang) |
| Draw email headers (will be used to overview the email list) More...
|
|
| drawMailboxControls ($imap, $type, $uid, $folder, $lang) |
| Draw mailbox control buttons (trash, reply, forward...) More...
|
|
| markAsFlagged ($imap, $uid) |
|
| moveMessage ($imap, $folder, $targetFolder, $uid) |
| Move a message from source to target folder. Requires imap handle, source folder, target folder and the mail UID to move. More...
|
|
| purgeTrash ($imap) |
| Cleanup trash and spam folder (delete all messages in requested folder) More...
|
|
| removeFlags ($imap, $uid) |
|
Integrated IMAP Webmail.
Integrated Webmail
YaWK includes a seamless integrated webmail. This means you can handle all emails of your website without leaving the backend. The seamless integration into the backend will help you with your daily work.
This class features all the basic webmail functions that are required to build the desired views. It also acts as wrapper for the imap client and serve some low-level API methods to move, purge, delete emails and more.
Beside this, this class serves methods to list folders and email headers / messages
- Author
- Daniel Retzl danie.nosp@m.lret.nosp@m.zl@gm.nosp@m.ail..nosp@m.com
- Copyright
- 2019 Daniel Retzl http://www.yawk.io @license https://opensource.org/licenses/MIT
- Version
- 1.0.0/
- Since
- File available since Release 1.0.0
Definition at line 24 of file webmail.php.
◆ deleteMessage()
YAWK\webmail::deleteMessage |
( |
|
$imap, |
|
|
|
$folder, |
|
|
|
$uid |
|
) |
| |
Delete a message. Requires imap handle, folder and uid of the mail to delete.
- Parameters
-
$imap | object imap connection resource |
$folder | string the source folder from which to move the uid |
$uid | int|string the mail UID |
- Parameters
-
$imap | \SSilence\ImapClient\ImapClient |
Definition at line 85 of file webmail.php.
References $folder, $imap, and $uid.
◆ drawFolders()
YAWK\webmail::drawFolders |
( |
|
$imap, |
|
|
|
$folders |
|
) |
| |
Draw a list with all folders of this mailbox.
- Parameters
-
$imap | object The current imap handle |
$folders | array The mailbox folders as array |
Definition at line 243 of file webmail.php.
247 if (is_array($folders) || (!empty($folders)))
253 $unreadMessages =
$imap->countUnreadMessages();
256 $activeMarkupDefault =
'';
259 if ($unreadMessages > 0)
261 $newMessagesLabel =
"<span id=\"newMessagesLabel\" class=\"label label-success pull-right\">+ ".$unreadMessages.
"</span>";
265 $newMessagesLabel =
"";
275 $messageCount =
$imap->countMessages();
278 if (isset(
$_GET[
'folder']) && (!empty(
$_GET[
'folder'])))
283 $activeMarkup =
" class=\"active\"";
284 $activeLabelNew = $newMessagesLabel;
285 $activeLabelInbox =
'';
286 $activeLabelTotal =
" <span id=\"messageCount_".$folder.
"\"><small>(".$messageCount.
")</small></span>";
291 $activeLabelNew =
'';
292 $activeLabelInbox =
'';
293 $activeLabelTotal =
" <span id=\"messageCount_".$folder.
"\"><small>(".$messageCount.
")</small></span>";
299 $activeLabelNew =
"";
300 $activeLabelTotal =
"";
301 $activeLabelInbox = $newMessagesLabel;
304 $activeLabelTotal =
" <span id=\"messageCount_".$folder.
"\"><small>(".$messageCount.
")</small></span>";
305 $activeMarkupDefault =
" class=\"active\"";
312 echo
"<li '".$activeMarkup.$activeMarkupDefault.
"><a href=\"index.php?page=webmail&folder=$folder\"><i class=\"fa fa-inbox\"></i> $folder
313 ".$activeLabelNew.
" ".$activeLabelInbox.
" ".$activeLabelTotal.
" </a></li>";
318 echo
"<li".$activeMarkup.
"><a href=\"index.php?page=webmail&folder=$folder\"><i class=\"fa fa-envelope-o\"></i> $folder
319 ".$activeLabelNew.
" ".$activeLabelTotal.
" </a></li>";
324 echo
"<li".$activeMarkup.
"><a href=\"index.php?page=webmail&folder=$folder\"><i class=\"fa fa-file-text-o\"></i> ".
$folder.
"
325 ".$activeLabelNew.
" ".$activeLabelTotal.
" </a></li>";
330 echo
"<li".$activeMarkup.
"><a href=\"index.php?page=webmail&folder=$folder\"><i class=\"fa fa-filter\"></i> ".
$folder.
"
331 ".$activeLabelNew.
" ".$activeLabelTotal.
" </a></li>";
336 echo
"<li".$activeMarkup.
"><a href=\"index.php?page=webmail&folder=$folder\"><i class=\"fa fa-trash-o\"></i> ".
$folder.
"
337 ".$activeLabelNew.
" ".$activeLabelTotal.
" </a></li>";
342 echo
"<li".$activeMarkup.
"><a href=\"index.php?page=webmail&folder=$folder\"><i class=\"fa fa-folder-o\"></i> ".
$folder.
"
343 ".$activeLabelNew.
" ".$activeLabelTotal.
" </a></li>";
349 echo
"Failed to draw folders because folders is not an array (or empty).";
if(!isset($language)||(!isset($lang))) $item
References $_GET, $folder, $imap, and $item.
◆ drawHeaders()
YAWK\webmail::drawHeaders |
( |
|
$emails, |
|
|
|
$currentFolder, |
|
|
|
$lang |
|
) |
| |
Draw email headers (will be used to overview the email list)
- Parameters
-
$emails | array email headers |
$currentFolder | string the current folder from where to get the emails |
$lang | array language array |
Definition at line 360 of file webmail.php.
362 if (is_array($emails) && (!empty($emails)))
368 if (
$email->header->seen === 0)
371 $boldRow =
"text-bold";
372 $seenIcon =
"fa fa-envelope text-muted";
373 $seenLink =
'index.php?page=webmail&markAsRead=true&folder='.$currentFolder.
'&msgno='.
$email->header->msgno.
'';
376 $messageLink =
'index.php?page=webmail-message&folder='.$currentFolder.
'&msgno='.
$email->header->msgno.
'';
377 $markAsReadIcon =
'<a id="seenIconLink_'.$email->header->msgno.
'" onclick="markAsSeen('.
$email->header->msgno.
', \''.$state.
'\');
return false;
" href="#
" '.$seenTooltip.'><i id="seenIcon_
'.$email->header->msgno.'" class="'.$seenIcon.'"></i></a>';
380 { // message already seen
381 $state = "setUnseen
";
383 $seenIcon = "fa fa-envelope-open-
o text-muted
";
384 $seenLink = 'index.php?page=webmail&markAsUnread=true&folder='.$currentFolder.'&msgno='.$email->header->msgno.'';
385 // $seenTooltip = 'data-toggle="tooltip
" data-container="body
" title="'.$lang['MARK_AS_UNSEEN
'].'" data-original-title="'.$lang['MARK_AS_UNSEEN
'].'"';
387 $messageLink = 'index.php?page=webmail-message&folder='.$currentFolder.'&msgno='.$email->header->msgno.'';
388 $markAsReadIcon = '<a id="seenIconLink_
'.$email->header->msgno.'" onclick="markAsSeen(
'.$email->header->msgno.', \
''.$state.
'\');
return false;
" href="#
" '.$seenTooltip.'><i id="seenIcon_
'.$email->header->msgno.'" class="'.$seenIcon.'"></i></a>';
392 $size = \YAWK\filemanager::sizeFilter($email->header->size, 0);
395 $attachment = count ($email->attachments);
397 // check if attachment is set
398 if ($attachment >= 1)
399 { // set paperclip icon
400 $attachClip = '<b><i class="fa fa-paperclip
"></i></b><br><small>'.$size.'</small>';
407 // calculate human friendly time info
408 $timeAgo = \YAWK\sys::time_ago($email->header->date, $lang);
410 if ($currentFolder == "trash
" || $currentFolder == "Trash
" || $currentFolder == "TRASH
")
413 // set action icon to "RESTORE
"
414 $markAsReadIcon = '<a id="moveIconLink_
'.$email->header->uid.'" onclick="moveMessage(
'.$email->header->uid.', \
''.$currentFolder.
'\', \
'Inbox\', );return false;" href="#"><i class="fa fa-undo text-dark" id="moveIcon_'.$email->header->uid.
'"></i></a>';
416 $deleteIcon =
'<a id="moveIconLink_'.$email->header->uid.
'" data-toggle="tooltip" data-container="body" title="'.
$lang[
'DELETE_FINALLY'].
'" data-original-title="'.
$lang[
'DELETE_FINALLY'].
'" onclick="deleteMessage('.
$email->header->uid.
', \''.$currentFolder.
'\');
return false;
" href="#
"><i class="fa fa-trash-
o" id="moveIcon_
'.$email->header->uid.'"></i></a>';
418 $spamIcon = '<a id="spamIconLink_
'.$email->header->uid.'" data-toggle="tooltip
" data-container="body
" title="'.$lang['SPAM
'].'" data-original-title="'.$lang['SPAM
'].'" onclick="moveMessage(
'.$email->header->uid.', \
''.$currentFolder.
'\', \
'Junk\');return false;" href="#"><i class="fa fa-filter" id="spamIcon_'.$email->header->uid.
'"></i></a>';
420 elseif ($currentFolder ==
"junk" || $currentFolder ==
"Junk" || $currentFolder ==
"JUNK"
421 || $currentFolder ==
"spam" || $currentFolder ==
"Spam" || $currentFolder ==
"SPAM")
423 $deleteIcon =
'<a id="moveIconLink_'.$email->header->uid.
'" data-toggle="tooltip" data-container="body" title="'.
$lang[
'RECYCLE_BIN'].
'" data-original-title="'.
$lang[
'RECYCLE_BIN'].
'" onclick="moveMessage('.
$email->header->uid.
', \''.$currentFolder.
'\', \
'Trash\');return false;" href="#"><i class="fa fa-trash-o" id="moveIcon_'.$email->header->uid.
'"></i></a>';
425 $spamIcon =
'<a id="spamIconLink_'.$email->header->uid.
'" data-toggle="tooltip" data-container="body" title="'.
$lang[
'MOVE_INBOX'].
'" data-original-title="'.
$lang[
'MOVE_INBOX'].
'" onclick="moveMessage('.
$email->header->uid.
', \''.$currentFolder.
'\', \
'INBOX\');return false;" href="#"><i class="fa fa-inbox" id="spamIcon_'.$email->header->uid.
'"></i></a>';
430 $deleteIcon =
'<a id="moveIconLink_'.$email->header->uid.
'" data-toggle="tooltip" data-container="body" title="'.
$lang[
'RECYCLE_BIN'].
'" data-original-title="'.
$lang[
'RECYCLE_BIN'].
'" onclick="moveMessage('.
$email->header->uid.
', \''.$currentFolder.
'\', \
'Trash\');return false;" href="#"><i class="fa fa-trash-o" id="moveIcon_'.$email->header->uid.
'"></i></a>';
432 $spamIcon =
'<a id="spamIconLink_'.$email->header->uid.
'" data-toggle="tooltip" data-container="body" title="'.
$lang[
'SPAM'].
'" data-original-title="'.
$lang[
'SPAM'].
'" onclick="moveMessage('.
$email->header->uid.
', \''.$currentFolder.
'\', \
'Junk\');return false;" href="#"><i class="fa fa-filter" id="spamIcon_'.$email->header->uid.
'"></i></a>';
436 if (
$email->header->flagged === 0)
438 $starIcon =
'<a id="starIconLink_'.$email->header->uid.
'" onclick="markAsFlagged('.
$email->header->uid.
', \'setFlagged\');return false;" href="#"><i id="starIcon_'.
$email->header->uid.
'" class="fa fa-star-o text-orange"></i></a>';
442 $starIcon =
'<a id="starIconLink_'.$email->header->uid.
'" onclick="markAsFlagged('.
$email->header->uid.
', \'setUnFlagged\');return false;" href="#"><i id="starIcon_'.
$email->header->uid.
'" class="fa fa-star text-orange"></i></a>';
450 <tr id="emailRow_'.$email->header->uid.
'">
451 <td><div class="icheckbox_flat-blue" aria-checked="false" aria-disabled="false" style="position: relative;"><input type="checkbox" style="position: absolute; opacity: 0;"><ins class="iCheck-helper" style="position: absolute; top: 0%; left: 0%; display: block; width: 100%; height: 100%; margin: 0px; padding: 0px; background: rgb(255, 255, 255); border: 0px; opacity: 0;"></ins></div></td>
452 <td class="mailbox-star">'.$markAsReadIcon.
'</td>
453 <td class="mailbox-star">'.$starIcon.
'</td>
454 <td id="mailboxName_'.
$email->header->msgno.
'" class="mailbox-name '.$boldRow.
'" style="cursor:pointer;" onclick="window.location=\''.$messageLink.
'\';
"><a href="#
">'.$email->header->from.'</a>
455 <br><small>'.$email->header->details->from[0]->mailbox.'@'.$email->header->details->from[0]->host.'</small></td>
456 <td id="mailboxSubject_
'.$email->header->msgno.'" class="mailbox-subject
'.$boldRow.'" style="cursor:pointer;
" onclick="window.location=\
''.$messageLink.
'\';
">'.$email->header->subject.'</td>
457 <td class="mailbox-attachment text-center
">'.$attachClip.'</td>
458 <td class="mailbox-
date">'.substr($email->header->date, 0, -6).'<br><small>'.$timeAgo.'</small></td>
459 <td class="mailbox-star
">'.$spamIcon.' '.$deleteIcon.'</td>
466 // echo "<
b>This folder is empty.</
b>
";
print $lang['FILEMAN_UPLOAD']
moveMessage($imap, $folder, $targetFolder, $uid)
Move a message from source to target folder. Requires imap handle, source folder, target folder and t...
References $email, $item, $lang, b(), date, YAWK\webmail\moveMessage(), o(), and window.
◆ drawMailboxControls()
YAWK\webmail::drawMailboxControls |
( |
|
$imap, |
|
|
|
$type, |
|
|
|
$uid, |
|
|
|
$folder, |
|
|
|
$lang |
|
) |
| |
Draw mailbox control buttons (trash, reply, forward...)
- Parameters
-
$imap | object imap object |
$type | string inbox|message| select proper button set which to display |
$uid | int the current email uid to work with |
$folder | string the current folder (to detect if folder is trash) |
$lang | array language array |
- Parameters
-
$imap | \SSilence\ImapClient\ImapClient |
Definition at line 141 of file webmail.php.
165 $deleteClassicLink =
"index.php?page=webmail&purgeTrash=true";
166 $deleteLink =
'<a id="moveIconLink_'.$uid.
'" onclick="moveMessage('.
$uid.
', \''.
$_GET[
'folder'].
'\', \
''.$folder.
'\');
return false;
" href="#
"><i class="fa fa-trash-
o" id="moveIcon_
'.$uid.'"></i></a>';
167 $deleteClass = "btn btn-
default btn-sm
";
168 $refreshClass = "btn btn-
default btn-sm hidden
";
169 $markAsReadClass = "btn btn-
default btn-sm checkbox-toggle hidden
";
172 { // move to trash link
173 $deleteClassicLink = "index.php?page=webmail&
moveMessage=
true&folder=
".$folder."&targetFolder=Trash&uid=
".$uid."";
174 if (!isset($_GET['folder']) || (empty($_GET['folder']))) { ($folder = 'Inbox'); } else { ($folder = $_GET['folder']); }
175 $deleteLink = '<a id="moveIconLink_
'.$uid.'" onclick="moveMessage(
'.$uid.', \
''.
$folder.
'\', \
'Trash\');return false;" href="#"><i class="fa fa-trash-o" id="moveIcon_'.$uid.
'"></i></a>';
176 $deleteClass =
"btn btn-default btn-sm hidden";
177 $refreshClass =
"btn btn-default btn-sm";
178 $markAsReadClass =
"btn btn-default btn-sm checkbox-toggle";
182 <div class=\"mailbox-controls\">
183 <!-- Check all button -->
184 <a href=\"#\" class=\"".$markAsReadClass.
"\" data-toggle=\"tooltip\" data-container=\"body\" title=\"$lang[MARK_ALL_AS_READ]\" data-original-title=\"$lang[MARK_ALL_AS_READ]\"><i class=\"fa fa-square-o\"></i></a>
185 <div class=\"btn-group\">";
188 echo
"<a href=\"".$deleteClassicLink.
"\" id=\"icon-trash\" class=\"".$deleteClass.
"\" data-toggle=\"tooltip\" data-container=\"body\" title=\"$lang[DELETE_ALL]\" data-original-title=\"$lang[DELETE_ALL]\"><i class=\"fa fa-trash-o\"></i> Empty Trash</a>
189 <a href=\"index.php?page=webmail\" id=\"icon-refresh\" class=\"".$refreshClass.
"\" data-toggle=\"tooltip\" data-container=\"body\" title=\"$lang[REFRESH]\" data-original-title=\"$lang[REFRESH]\"><i class=\"fa fa-refresh\"></i></a>
192 <!-- additional buttons: settings + new mail -->
193 <div class=\"pull-right\">
194 <a href=\"index.php?page=settings-webmail\" id=\"icon-settings\" class=\"btn btn-default btn-sm\" data-toggle=\"tooltip\" data-container=\"body\" title=\"$lang[SETTINGS]\" data-original-title=\"$lang[SETTINGS]\"><i class=\"fa fa-gear\"></i></a>
195 <a href=\"index.php?page=webmail-compose\" id=\"icon-compose\" class=\"btn btn-default btn-sm\" data-toggle=\"tooltip\" data-container=\"body\" title=\"$lang[EMAIL_COMPOSE]\" data-original-title=\"$lang[EMAIL_COMPOSE]\"><i class=\"fa fa-plus\"></i></a>
206 $deleteLink =
"index.php?page=webmail&purgeTrash=true";
207 $deleteClass =
"btn btn-default btn-sm";
212 $deleteClass =
"btn btn-default btn-sm";
214 $deleteLink =
'<a id="moveIconLink_'.$uid.
'" class="btn btn-default btn-sm" onclick="moveMessage('.
$uid.
', \''.
$folder.
'\', \
'Trash\');return false;" href="#" title="'.$lang[
'DELETE'].
'" data-toggle="tooltip" data-container="body" data-original-title="'.
$lang[
'DELETE'].
'"><i class="fa fa-trash-o" id="moveIcon_'.
$uid.
'"></i></a>';
217 <div class=\"mailbox-controls\">
218 <div class=\"btn-group\">
219 <a id=\"btn-markAsUnseen\" href=\"index.php?page=webmail-message&markAsUnread=true&folder=".$_GET[
'folder'].
"&msgno=".
$_GET[
'msgno'].
"\" class=\"btn btn-default btn-sm\" data-toggle=\"tooltip\" data-container=\"body\" title=\"$lang[MARK_AS_UNSEEN]\" data-original-title=\"$lang[MARK_AS_UNSEEN]\"><i class=\"fa fa-envelope\" id=\"icon-markAsUnseen\"></i></a>
224 echo
"<a id=\"icon-reply\" href=\"#summernote\" class=\"btn btn-default btn-sm\" data-toggle=\"tooltip\" data-container=\"body\" title=\"$lang[REPLY]\" data-original-title=\"$lang[REPLY]\"><i class=\"fa fa-reply\"></i></a>
225 <a href=\"index.php?page=webmail\" id=\"icon-forward\" class=\"btn btn-default btn-sm\" data-toggle=\"tooltip\" data-container=\"body\" title=\"$lang[FORWARD]\" data-original-title=\"$lang[FORWARD]\"><i class=\"fa fa-mail-forward\"></i></a>
226 <a href=\"#\" id=\"icon-print\" class=\"btn btn-default btn-sm\" data-toggle=\"tooltip\" data-container=\"body\" title=\"$lang[PRINT]\" data-original-title=\"$lang[PRINT]\"><i class=\"fa fa-print\"></i></a>
228 <div class=\"btn-group pull-right\">
229 <a href=\"index.php?page=webmail-compose\" id=\"icon-compose\" class=\"btn btn-default btn-sm\" data-toggle=\"tooltip\" data-container=\"body\" title=\"\" data-original-title=\"Email verfassen\"><i class=\"fa fa-plus\"></i></a>
References $_GET, $folder, $lang, $type, $uid, YAWK\webmail\moveMessage(), and o().
◆ markAsFlagged()
YAWK\webmail::markAsFlagged |
( |
|
$imap, |
|
|
|
$uid |
|
) |
| |
Mark email as flagged
- Parameters
-
- Returns
- bool
Definition at line 477 of file webmail.php.
480 return imap_setflag_full(
$imap,
$uid,
"\\Flagged", ST_UID);
◆ moveMessage()
YAWK\webmail::moveMessage |
( |
|
$imap, |
|
|
|
$folder, |
|
|
|
$targetFolder, |
|
|
|
$uid |
|
) |
| |
Move a message from source to target folder. Requires imap handle, source folder, target folder and the mail UID to move.
- Parameters
-
$imap | object imap connection resource |
$folder | string the source folder from which to move the uid |
$targetFolder | string the target folder where to move the uid |
$uid | int|string the mail UID |
- Parameters
-
$imap | \SSilence\ImapClient\ImapClient |
Definition at line 36 of file webmail.php.
48 if (!isset($targetFolder) || (empty($targetFolder)))
69 if (
$imap->moveMessage(
$uid, $targetFolder))
References $folder, $imap, and $uid.
Referenced by YAWK\webmail\drawHeaders(), and YAWK\webmail\drawMailboxControls().
◆ purgeTrash()
YAWK\webmail::purgeTrash |
( |
|
$imap | ) |
|
Cleanup trash and spam folder (delete all messages in requested folder)
- Parameters
-
$imap | object imap connection resource |
- Parameters
-
$imap | \SSilence\ImapClient\ImapClient |
Definition at line 120 of file webmail.php.
123 if (
$imap->purge() ==
true)
References $imap.
◆ removeFlags()
YAWK\webmail::removeFlags |
( |
|
$imap, |
|
|
|
$uid |
|
) |
| |
Clear flags from email
- Parameters
-
- Returns
- bool
Definition at line 489 of file webmail.php.
491 return imap_clearflag_full(
$imap,
$uid,
"\\Flagged", ST_UID);
◆ $connectionInfo
YAWK\webmail::$connectionInfo = '' |
- Parameters
-
string | information about the connection |
Definition at line 27 of file webmail.php.
The documentation for this class was generated from the following file: