Write essential hooks for mailu integration
This commit is contained in:
parent
4919aaf8d8
commit
39daf5524c
@ -72,106 +72,82 @@ class UserHooks {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
private function createImapFolders($user_data) {
|
|
||||||
// $server = 'mail.glesys.se';
|
|
||||||
// $email = $user_data['email'];
|
|
||||||
// $passw = $user_data['password'];
|
|
||||||
// $folders = array('Sent', 'Drafts', 'Trash', 'Junk', 'Archive');
|
|
||||||
// $mbox = \imap_open("{" . $server . "}", $email, $passw, OP_HALFOPEN);
|
|
||||||
// if(!$mbox){
|
|
||||||
// $message = "can't connect: " . \imap_last_error();
|
|
||||||
// $this->logger->error($message);
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// foreach ($folders as $folder) {
|
|
||||||
// if (! @\imap_createmailbox(
|
|
||||||
// $mbox,
|
|
||||||
// \imap_utf7_encode("{".$server."}INBOX.".$folder))) {
|
|
||||||
// $message = 'Error creating ' . $folder . ' folder: ' .
|
|
||||||
// \imap_last_error();
|
|
||||||
// $this->logger->error($message);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// \imap_close($mbox);
|
|
||||||
// return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function createEmailAccount($user_data) {
|
private function createEmailAccount($user_data) {
|
||||||
// $keys = $this->config->getGlesysKeys();
|
$ch = curl_init($this.config->getMailUAPI . 'user');
|
||||||
// $fields = array(
|
$payload = json_encode($user_data);
|
||||||
// 'emailaccount' => $user_data['email'],
|
curl_setopt($ch, CURLOPT_POST, 1);
|
||||||
// 'password' => $user_data['password'],
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload );
|
||||||
// 'quota' => $user_data['quota']
|
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json',
|
||||||
// );
|
'Authorization:' . $this->config->getMailUKeys()));
|
||||||
// $query = http_build_query($fields);
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true );
|
||||||
// $ch = curl_init();
|
$result = curl_exec($ch);
|
||||||
// curl_setopt($ch, CURLOPT_URL,
|
|
||||||
// 'https://api.glesys.com/email/createaccount/');
|
if (curl_errno($ch)) {
|
||||||
// curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
$message = 'createEmailAccount Error:' . curl_error($ch);
|
||||||
// curl_setopt($ch, CURLOPT_POST, 1);
|
$this->logger->error($message);
|
||||||
// curl_setopt($ch, CURLOPT_USERPWD, $keys);
|
return false;
|
||||||
// curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
|
}
|
||||||
// $result = curl_exec($ch);
|
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||||
// if (curl_errno($ch)) {
|
curl_close($ch);
|
||||||
// $message = 'Error:' . curl_error($ch);
|
|
||||||
// $this->logger->error($message);
|
if ($code == 200) {
|
||||||
// return false;
|
return true;
|
||||||
// }
|
}
|
||||||
// curl_close($ch);
|
|
||||||
// $xml = simplexml_load_string($result);
|
$this->logger->error("createEmailAccount returned ".$code." message: ".$result);
|
||||||
// $code = $xml->status->code;
|
return false;
|
||||||
// if ($code == 200) return $this->createImapFolders($user_data);
|
|
||||||
// else $this->logger->warning(
|
|
||||||
// "Error: non-200 status: " . $xml->status->text);
|
|
||||||
// return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function deleteEmailAccount($user_data) {
|
private function deleteEmailAccount($user_data) {
|
||||||
// $ch = curl_init();
|
$ch = curl_init($this.config->getMailUAPI . 'user/' . urlencode($user_data->email));
|
||||||
// $keys = $this->config->getGlesysKeys();
|
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: ' . $this->config->getMailUKeys()));
|
||||||
// curl_setopt($ch, CURLOPT_URL, 'https://api.glesys.com/email/delete/');
|
|
||||||
// curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
|
||||||
// curl_setopt($ch, CURLOPT_POSTFIELDS, "email=" . $user_data["email"]);
|
|
||||||
// curl_setopt($ch, CURLOPT_POST, 1);
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true );
|
||||||
// curl_setopt($ch, CURLOPT_USERPWD, $keys);
|
$result = curl_exec($ch);
|
||||||
// $result = curl_exec($ch);
|
|
||||||
// if (curl_errno($ch)) {
|
if (curl_errno($ch)) {
|
||||||
// $message = 'Error: ' . curl_error($ch);
|
$message = 'deleteEmailAccount Error:' . curl_error($ch);
|
||||||
// $this->logger->error($message);
|
$this->logger->error($message);
|
||||||
// return false;
|
return false;
|
||||||
// }
|
}
|
||||||
// curl_close($ch);
|
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||||
// return true;
|
curl_close($ch);
|
||||||
|
|
||||||
|
if ($code == 200) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->logger->error("deleteEmailAccount returned ".$code." message: ".$result);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function updateEmailPassword($user_data) {
|
private function updateEmailPassword($user_data) {
|
||||||
// $keys = $this->config->getGlesysKeys();
|
$ch = curl_init($this.config->getMailUAPI . 'user/' . urlencode($user_data->email));
|
||||||
// $fields = array(
|
$payload = json_encode(array("raw_password" => $user_data['password']));
|
||||||
// 'emailaccount' => $user_data['email'],
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload );
|
||||||
// 'password' => $user_data['password']
|
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json',
|
||||||
// );
|
'Authorization:' . $this->config->getMailUKeys()));
|
||||||
// $query = http_build_query($fields);
|
|
||||||
// $ch = curl_init();
|
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PATCH");
|
||||||
// curl_setopt($ch, CURLOPT_URL,
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true );
|
||||||
// 'https://api.glesys.com/email/editaccount/');
|
$result = curl_exec($ch);
|
||||||
// curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
|
||||||
// curl_setopt($ch, CURLOPT_POST, 1);
|
if (curl_errno($ch)) {
|
||||||
// curl_setopt($ch, CURLOPT_USERPWD, $keys);
|
$message = 'updateEmailPassword Error:' . curl_error($ch);
|
||||||
// curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
|
$this->logger->error($message);
|
||||||
// $result = curl_exec($ch);
|
return false;
|
||||||
// if (curl_errno($ch)) {
|
}
|
||||||
// $message = 'Error:' . curl_error($ch);
|
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||||
// $this->logger->error($message);
|
curl_close($ch);
|
||||||
// return false;
|
|
||||||
// }
|
if ($code == 200) {
|
||||||
// curl_close($ch);
|
return true;
|
||||||
// $xml = simplexml_load_string($result);
|
}
|
||||||
// $code = $xml->status->code;
|
|
||||||
// if ($code != 200){
|
$this->logger->error("updateEmailPassword returned ".$code." message: ".$result);
|
||||||
// $this->logger->warning(
|
return false;
|
||||||
// "Error: non-200 status: " . $xml->status->text);
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user