YaWK  24.1
Yet another WebKit
webmail-deleteMessage.php
Go to the documentation of this file.
1 
2 
3 
4 
5 <?php
6 // include required imap classes
7 require_once "../../system/engines/imapClient/ImapClient.php";
8 require_once "../../system/engines/imapClient/ImapClientException.php";
9 require_once "../../system/engines/imapClient/ImapConnect.php";
10 // include required yawk classes
11 require_once '../../system/classes/db.php';
12 require_once '../../system/classes/settings.php';
13 require_once '../../system/classes/webmail.php';
14 // create db object
15 $db = new \YAWK\db();
16 // create webmail object
17 $webmail = new \YAWK\webmail();
18 
19 // let php know we need these classes:
20 use SSilence\ImapClient\ImapClientException;
21 use SSilence\ImapClient\ImapClient as Imap;
22 
23 // get all webmail setting values into an array
25 // mailbox server (imap.server.tld)
26 $server = $webmailSettings['webmail_imap_server'];
27 // mailbox user ([email protected])
28 $username = $webmailSettings['webmail_imap_username'];
29 // mailbox password
30 $password = $webmailSettings['webmail_imap_password'];
31 // encryption type (ssl, tsl, null)
32 $encryption = "/" . $webmailSettings['webmail_imap_encrypt'];
33 // port (default: 993)
34 $port = ":" . $webmailSettings['webmail_imap_port'];
35 // novalidate-cert
36 $novalidate = $webmailSettings['webmail_imap_novalidate'];
37 // create options array
39 
40 // lets go: open imap connection, check state and toggle required
41 try
42 { // open connection to imap server
43  $imap = new Imap($server.$port.$encryption, $username, $password, $encryption, 0, 0, $options);
44  // connection successful, error = false
45  $error = false;
46 
47  // @var $_POST['state'] string (seen|unseen) : check which state should be toggled
48  if (isset($_POST['folder']) && (isset($_POST['uid'])))
49  { // if email should be toggled to state 'not flagged'
50  if ($webmail->deleteMessage($imap, $_POST['folder'], $_POST['uid']))
51  { // email deleted
52  echo "true";
53  }
54  else
55  { // failed to delete email
56  echo "false";
57  // \YAWK\alert::draw("danger", "ERROR:", "Unable to delete email", "", 2800);
58  }
59  }
60 }
61  // open imap connection failed...
62 catch (ImapClientException $error)
63 { // no errors in production...
64  echo "false";
65  echo "<script>console.log('.$error.');</script>";
66 }
67 ?>
static getValueSettingsArray($db, $property)
Returns an array containing property as key and values corresponding to this property where p like $p...
Definition: settings.php:41