-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathjson.php
29 lines (26 loc) · 878 Bytes
/
json.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
// include Imap.Class
include_once('lib/class.imap.php');
$email = new Imap();
$connect = $email->connect(
'{mail.bachors.com:123/notls}INBOX', //host
'[email protected]', //username
'xxxxxxx' //password
);
header('Content-Type: application/json');
header('Access-Control-Allow-Origin: *');
if($connect){
if(isset($_POST['inbox'])){
// inbox array
$inbox = $email->getMessages('html');
echo json_encode($inbox, JSON_PRETTY_PRINT);
}else if(!empty($_POST['uid']) && !empty($_POST['part']) && !empty($_POST['file']) && !empty($_POST['encoding'])){
// attachments
$inbox = $email->getFiles($_POST);
echo json_encode($inbox, JSON_PRETTY_PRINT);
}else {
echo json_encode(array("status" => "error", "message" => "Not connect."), JSON_PRETTY_PRINT);
}
}else{
echo json_encode(array("status" => "error", "message" => "Not connect."), JSON_PRETTY_PRINT);
}