Guillermo Giuliana 791e0969e9
add script and change 4.7.0 to 4.8.0 (#848)
* add script and change 4.7.0 to 4.8

* change end of line 4.8.0 script

* Delete main.py
2020-07-22 07:32:18 -03:00

44 lines
1.0 KiB
PHP
Executable File

<?php
/**
* @api {post} /system/test-imap Test IMAP Connection
* @apiVersion 4.8.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);
}
}
}