2018-12-24 01:44:59 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @api {post} /system/test-imap Test IMAP Connection
|
2019-03-06 16:47:24 +01:00
|
|
|
* @apiVersion 4.4.0
|
2018-12-24 01:44:59 +01:00
|
|
|
*
|
|
|
|
* @apiName Test IMAP Connection
|
|
|
|
*
|
|
|
|
* @apiGroup System
|
|
|
|
*
|
|
|
|
* @apiDescription Test if the given values connect correctly to a IMAP server.
|
|
|
|
*
|
|
|
|
* @apiPermission any
|
|
|
|
*
|
|
|
|
* @apiParam {String} imap-host Host of the IMAP server.
|
|
|
|
* @apiParam {String} imap-user User for the IMAP server.
|
|
|
|
* @apiParam {String} imap-pass Password for the IMAP server.
|
|
|
|
*
|
2019-01-12 04:38:33 +01:00
|
|
|
* @apiUse IMAP_CONNECTION
|
2018-12-24 01:44:59 +01:00
|
|
|
*
|
|
|
|
* @apiSuccess {Object} data Empty object
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2019-01-12 04:38:33 +01:00
|
|
|
class TestIMAPController extends Controller {
|
|
|
|
const PATH = '/test-imap';
|
2018-12-24 01:44:59 +01:00
|
|
|
const METHOD = 'POST';
|
|
|
|
|
|
|
|
public function validations() {
|
|
|
|
return [
|
|
|
|
'permission' => 'any',
|
|
|
|
'requestData' => []
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function handler() {
|
2019-01-12 06:31:09 +01:00
|
|
|
if(imap_open(Controller::request('imap-host'), Controller::request('imap-user'), Controller::request('imap-pass'))) {
|
2018-12-24 01:44:59 +01:00
|
|
|
Response::respondSuccess();
|
|
|
|
} else {
|
|
|
|
throw new RequestException(ERRORS::IMAP_CONNECTION);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|