Guillermo Giuliana 6a34c24d7d
update script and change 4.6 to 4.7 (#809)
* update script and change 4.6 to 4.7

* fix 4.7.0 script
2020-06-16 21:26:04 -03:00

44 lines
1.0 KiB
PHP
Executable File

<?php
/**
* @api {post} /system/test-imap Test IMAP Connection
* @apiVersion 4.7.0
*
* @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.
*
* @apiUse IMAP_CONNECTION
*
* @apiSuccess {Object} data Empty object
*
*/
class TestIMAPController extends Controller {
const PATH = '/test-imap';
const METHOD = 'POST';
public function validations() {
return [
'permission' => 'any',
'requestData' => []
];
}
public function handler() {
if(imap_open(Controller::request('imap-host'), Controller::request('imap-user'), Controller::request('imap-pass'))) {
Response::respondSuccess();
} else {
throw new RequestException(ERRORS::IMAP_CONNECTION);
}
}
}