/** * @param $payload * @param $options * * @return mixed */ public function Send($payload, $options = []) { if ($this->_certificate == null) { return false; } $alert = isset($options[self::OPTION_ALERT]) ? $options[self::OPTION_ALERT] : ''; $data = $payload; if (is_scalar($payload)) { $alert = $payload; $data = array(); } $this->_payload = array('aps' => array('alert' => $alert, 'badge' => isset($options[self::OPTION_BADGE]) ? $options[self::OPTION_BADGE] : 1, 'sound' => isset($options[self::OPTION_SOUND]) ? $options[self::OPTION_SOUND] : 'default'), 'data' => $data); $client = new QuarkClient($this->_host, $this, $this->_certificate, 1); return $client->Connect(); }
/** * @param QuarkClient $client * * @return mixed */ public function Client(QuarkClient $client) { $conn = $client->Connect(); if (!$conn) { Quark::Log('Mail. Unable to connect to mail server. Error: ' . $client->Error(true)); return false; } $smtp = $this->_config->SMTP(); $this->_dto->Header(QuarkDTO::HEADER_CONTENT_TRANSFER_ENCODING, QuarkDTO::TRANSFER_ENCODING_BASE64); try { $this->_cmd($client, 220); $this->_cmd($client, 250, 'HELO Quark'); $this->_cmd($client, 334, 'AUTH LOGIN'); $this->_cmd($client, 334, base64_encode($smtp->user)); $this->_cmd($client, 235, base64_encode($smtp->pass)); $this->_cmd($client, 250, 'MAIL FROM: <' . $smtp->user . '>'); foreach ($this->_receivers as $receiver) { $this->_cmd($client, 250, 'RCPT TO: <' . $receiver . '>'); } $this->_cmd($client, 354, 'DATA'); $this->_cmd($client, 250, $this->_dto->SerializeResponseBody() . "\r\n."); $this->_cmd($client, 221, 'QUIT'); } catch (QuarkArchException $e) { return false; } return $client->Close(); }