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