-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmailwh.php
More file actions
55 lines (55 loc) · 1.82 KB
/
Copy pathmailwh.php
File metadata and controls
55 lines (55 loc) · 1.82 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
set_time_limit(0);
if(php_sapi_name()!="cli") {
echo "NO CLI MODE \n";
exit();
}
require_once(__DIR__ . '/etc/init.php');
if(php_sapi_name()!="cli") {
define('DOC_ROOT', $_SERVER['DOCUMENT_ROOT']);
}else{
define('DOC_ROOT', "/var/web/ex/www");
}
$host = 'mail.tks.ms';
$user = 'tbot@tks.ms';
$pass = 'sFx1Doobay$5!9';
$port = 993;
$ssl = true;
$folder = 'INBOX';
$mailbox = new \JJG\Imap($host, $user, $pass, $port, $ssl, $folder);
$ids = $mailbox->getMessageIds();
if(count($ids)>0) {
echo "Mail's detected, count (".count($ids).")\n";
foreach ($ids as $k => $v) {
$msg=array();
try {
$msg = $mailbox->getMessage($k);
$msg['body'] = \Botb\Basic::convertMessageEncodingOfEMStructure($mailbox->getStructure($k),$msg['body']);
$resp = new \modules\mail_imap\Responder($msg['body']);
$reply = $resp->run();
if(is_array($reply)){
//[0] - Message
//[1] - BinaryData
//[2] - isHtml
$message = new \BotbLib\Tmail\Emessage($config['fmail'],$config['nfmail']);
$message->to($msg['from']);
$message->subject = "Ответ на " . imap_utf8($msg['subject']);
if(!$reply[2]){
$message->addData('attachment.png',$reply[1],'image/png');
}
$message->send();
}else {
$nmsg = array();
$nmsg['to'] = $msg['from'];
$nmsg['title'] = "Ответ на " . imap_utf8($msg['subject']);
$nmsg['message'] = $reply;
\Botb\Basic::sendmail($nmsg);
}
$mailbox->deleteMessage($k);
} catch (Exception $e) {
echo $e->getMessage();
}
}
$mailbox->expunge();
}
$ids=array();