/** * Send the given Message. * * Recipient/sender data will be retrieved from the Message API. * The return value is the number of recipients who were accepted for delivery. * * @param MessageInterface $message * * @return int */ public function send(MessageInterface $message) { $smtp_conn = fsockopen($this->host, $this->port, $errno, $errstr, 10); $log = $this->get_data($smtp_conn); fputs($smtp_conn, "EHLO " . $this->username . "\r\n"); $log = $this->get_data($smtp_conn); fputs($smtp_conn, "AUTH LOGIN\r\n"); $log = $this->get_data($smtp_conn); fputs($smtp_conn, base64_encode($this->username) . "\r\n"); $log = $this->get_data($smtp_conn); fputs($smtp_conn, base64_encode($this->password) . "\r\n"); $log = $this->get_data($smtp_conn); $size_msg = strlen($message->toString()); fputs($smtp_conn, "MAIL FROM:<" . $this->username . "> SIZE=" . $size_msg . "\r\n"); $log = $this->get_data($smtp_conn); foreach ($message->getTo() as $userMail => $userName) { fputs($smtp_conn, "RCPT TO: <" . $userMail . ">" . "\r\n"); $log = $this->get_data($smtp_conn); } fputs($smtp_conn, "DATA" . "\r\n"); $log = $this->get_data($smtp_conn); fputs($smtp_conn, $message->toString() . "\r\n.\r\n"); $log = $this->get_data($smtp_conn); fputs($smtp_conn, "QUIT\r\n"); $log = $this->get_data($smtp_conn); return count($message->getTo()); }
/** * Create JSON payload * * @param MessageInterface $message * * @return string */ public function createJsonPayload(MessageInterface $message) { if (version_compare(PHP_VERSION, '5.4.0', '>=')) { return json_encode($message->getPayloadData(), JSON_FORCE_OBJECT ^ JSON_UNESCAPED_UNICODE); } else { return json_encode($message->getPayloadData(), JSON_FORCE_OBJECT); } }
/** * Send the given Message. * * Recipient/sender data will be retrieved from the Message API. * The return value is the number of recipients who were accepted for delivery. * * @param MessageInterface $message * * @return int */ public function send(MessageInterface $message) { if (!array_key_exists('host', $this->configuration) || !array_key_exists('port', $this->configuration) || !array_key_exists('username', $this->configuration) || !array_key_exists('password', $this->configuration)) { return 0; } $messageStr = $message->toString(); $toStr = $this->getTo($messageStr, true); $to = $this->getTo($messageStr); $from = $this->getFrom($messageStr); $subject = $message->getSubject(); $endHeaders = strpos($messageStr, MessageInterface::LINE_SEPARATOR . MessageInterface::LINE_SEPARATOR); $headers = substr($messageStr, 0, $endHeaders); $body = substr($messageStr, $endHeaders + 4); foreach ($from as $address => $name) { $from_email = $address; $from_name = $name; } $smtp_host = $this->configuration['host']; $smtp_port = $this->configuration['port']; $user = $this->configuration['username']; $pass = $this->configuration['password']; $from_email = isset($from_email) && !empty($from_email) ? $from_email : $user; if (!($socket = fsockopen($smtp_host, $smtp_port, $errno, $errstr, 15))) { return 0; } $this->serverParse($socket, '220'); fwrite($socket, 'EHLO smtp.gmail.com' . Message::LINE_SEPARATOR); $this->serverParse($socket, '250', __LINE__); fwrite($socket, 'AUTH LOGIN' . Message::LINE_SEPARATOR); $this->serverParse($socket, '334', __LINE__); fwrite($socket, base64_encode($user) . Message::LINE_SEPARATOR); $this->serverParse($socket, '334', __LINE__); fwrite($socket, base64_encode($pass) . Message::LINE_SEPARATOR); $this->serverParse($socket, '235', __LINE__); fwrite($socket, 'MAIL FROM: <' . $from_email . '>' . Message::LINE_SEPARATOR); $this->serverParse($socket, '250', __LINE__); foreach ($to as $email => $name) { fwrite($socket, 'RCPT TO: <' . $email . '>' . Message::LINE_SEPARATOR); $this->serverParse($socket, '250', __LINE__); } fwrite($socket, 'DATA' . Message::LINE_SEPARATOR); $this->serverParse($socket, '354', __LINE__); fwrite($socket, 'Subject: ' . $subject . Message::LINE_SEPARATOR . 'To: ' . $toStr . Message::LINE_SEPARATOR . $headers . Message::LINE_SEPARATOR . Message::LINE_SEPARATOR . $body . Message::LINE_SEPARATOR); fwrite($socket, '.' . Message::LINE_SEPARATOR); $this->serverParse($socket, '250', __LINE__); fwrite($socket, 'QUIT' . Message::LINE_SEPARATOR); fclose($socket); return count($to); }
/** * Send the given Message. * * Recipient/sender data will be retrieved from the Message API. * The return value is the number of recipients who were accepted for delivery. * * @param MessageInterface $message * @return int */ public function send(MessageInterface $message) { $messageStr = $message->toString(); $toArr = $this->getTo($messageStr); $to = implode(', ', array_keys($toArr)); $subject = $message->getSubject(); $endHeaders = strpos($messageStr, MessageInterface::LINE_SEPARATOR . MessageInterface::LINE_SEPARATOR); $headers = substr($messageStr, 0, $endHeaders); $body = substr($messageStr, $endHeaders + 4); if (!mail($to, $subject, $body, $headers)) { return 0; } else { return count($message->getTo()); } }
/** * Send the given Message. * * Recipient/sender data will be retrieved from the Message API. * The return value is the number of recipients who were accepted for delivery. * * @param MessageInterface $message * * @return int */ public function send(MessageInterface $message) { $eol = Message::LINE_SEPARATOR; $messageString = $message->toString(); $startBoundary = strpos($messageString, 'boundary'); $endBoundary = strpos($messageString, $eol . $eol, $startBoundary); $startContent = $endBoundary; $content = substr($messageString, $startContent + strlen($eol . $eol)); $messageString = substr_replace($messageString, '', $startContent) . $eol . $eol; $messageString = str_replace($eol . 'boundary', $eol . ' ' . 'boundary', $messageString); $content = str_replace($eol . 'boundary', $eol . ' ' . 'boundary', $content); if (mail(null, null, $content, $messageString)) { return count($message->getTo()); } else { return '0'; } }
/** * Clear all messages except sticky * * @return $this */ public function clear() { foreach ($this->messages as $type => $messages) { foreach ($messages as $id => $message) { /** @var $message MessageInterface */ if (!$message->getIsSticky()) { unset($this->messages[$type][$id]); } } if (empty($this->messages[$type])) { unset($this->messages[$type]); } } if ($this->lastAddedMessage instanceof MessageInterface && !$this->lastAddedMessage->getIsSticky()) { $this->lastAddedMessage = null; } return $this; }
/** * {inheritdoc} */ public function getLevel() { return $this->message->getLevel(); }
public function parse() { parent::parse(); $this->text = trim($this->rawData['text']); }
/** * Serialize message to logger context * * @param MessageInterface $message * * @return array */ private function messageLoggerContext(MessageInterface $message) { return ['id' => $message->getId(), 'created' => $message->getCreated(), 'type' => $message->getType(), 'payload' => $message->getPayload()]; }
/** * Build reply XML. * * @param string $to * @param string $from * @param MessageInterface $message * * @return string */ protected function buildReply($to, $from, $message) { $base = ['ToUserName' => $to, 'FromUserName' => $from, 'CreateTime' => time(), 'MsgType' => $message->getType()]; return XML::build(array_merge($base, $this->transformer->transform($message))); }
public static function createFromRequest(MessageInterface $request, $content, $statusCode, $headers = []) { return new self($statusCode, $request->getScheme(), $request->getSchemeVersion(), $headers, $content); }
/** * Returns the HTTP version. * * @return string */ function getHttpVersion() { return $this->inner->getHttpVersion(); }
protected function __construct(array $message) { parent::__construct($message); $this->lat = $message['location']['latitude']; $this->lng = $message['location']['longitude']; }
/** * {@inheritdoc} */ public function serialize(MessageInterface $message) { return json_encode(['message' => ['id' => $message->getId(), 'type' => $message->getType(), 'created' => $message->getCreated(), 'payload' => $message->getPayload()]]); }