Store mail to file.
@param  Message $message
@return int
545683
public function send(Message $message)
	{
		$content = $message->generateMessage();

		preg_match('~Message-ID: <(?<message_id>\w+)[^>]+>~', $content, $matches);

		$path = $this->tempDir . '/'. $this->prefix . $matches['message_id'] . '.' . self::FILE_EXTENSION;
		if (($bytes = file_put_contents($path, $content)) === FALSE) {
			throw new InvalidStateException("Unable to write email to '$path'.");
		}

		return $bytes;
	}
974211
private function formMessageData(Message $message)
    {
        $data = array(
            'registration_ids' => $message->getRegistrationIds(),
        );

        $dataFields = array(
            'registration_ids' => 'getRegistrationIds',
            'collapse_key' => 'getCollapseKey',
            'data' => 'getData',
            'notification' => 'getNotification',
            'delay_while_idle' => 'getDelayWhileIdle',
            'time_to_live' => 'getTtl',
            'restricted_package_name' => 'getRestrictedPackageName',
            'dry_run' => 'getDryRun',
            'content_available' => 'getContentAvailable',
            'priority' => 'getPriority',
        );

        foreach ($dataFields as $fieldName => $getter) {
            if ($message->$getter() != null) {
                $data[$fieldName] = $message->$getter();
            }
        }

        return $data;
    }
544118
public function send(Message $message)
    {
        $em = $this->getEventManager();
        $event = $this->getEvent();
        $event->setMessage($message);
        $event->setName(SenderEvent::EVENT_SEND_PRE);
        $em->triggerEvent($event);
        $this->transport->send($message);
        $event->setName(SenderEvent::EVENT_SEND_POST);
        $em->triggerEvent($event);
    }
1343136
public function write_message($message)
  {
    $binary_length = strlen($message);
    
    $max_binary_frame_length = BUFFER_SIZE - 4;
    $sended_length = 0;
    
    $frames = array();
    while ($sended_length < $binary_length) {
      $not_sended_length = $binary_length - $sended_length;
      $binary_frame_length = ($not_sended_length > $max_binary_frame_length) ? $max_binary_frame_length : $not_sended_length;
      $frames[] = substr($message, $sended_length, $binary_frame_length);
      $sended_length += $binary_frame_length;
    }
    
    $header = pack("N", self::$serial++).pack("N", count($frames));
    //socket_send ($this->socket, $header, strlen($header) , 0);
    $x = socket_write ($this->socket, $header, strlen($header));
    foreach ($frames as $frame) {
      $msg = pack("N", strlen($frame)).$frame;
      socket_write ( $this->socket, $msg, strlen($msg));
    }
    
  }
189308
static public function calculateForMessage(Message $message)
    {
        $dto = $message->toDTO();

        if (empty($dto["payload"]))
            return 0;

        // message fee is 0.05 (current fee factor) multiplied
        // by the count of *started* 31 characters chunks.
        $chunks = floor((strlen($dto["payload"]) / 2) / 32);
        return Fee::FEE_FACTOR * ($chunks + 1);
    }
313221
public function a($message) {
        return isset($this->messages[$message]) ? $this->messages[$message] : $message;
    }
1329678
public function send(MailMessage $message)
    {
        $msg = \Swift_Message::newInstance();

        $type = $message->getHtml() ? 'text/html' : null;

        $msg->setSubject($message->getSubject())
            ->setTo($message->getTo())
            ->setFrom($message->getFrom())
            ->setCc($message->getCc())
            ->setBcc($message->getBcc())
            ->setReplyTo($message->getReplyTo())
            ->setBody($message->getBody(), $type, 'utf8');

        $files = $message->getFiles();

        foreach ($files as $file) {
            $attach = \Swift_Attachment::newInstance();

            if ($file->getFilename()) {
                $attach->setFilename($file->getFilename());
            }

            if ($file->getContentType()) {
                $attach->setContentType($file->getContentType());
            }

            $attach->setBody($file->getBody());

            $msg->attach($attach);
        }

        return $this->getMailer()->send($msg);
    }
125597
public function sendMessage(Message $message)
    {
        $this->currentId++;
        $messageData = $message->convertToRconData($this->currentId);
        $this->client->write($messageData);

        return $this->getResponseMessage();
    }
568182
public function send(Message $message)
	{
		// Queue the message and flush the associated gateway
		$messageEnvelope = $this->queue($message);
		$this->flush( $message->getCertificate() );

		// Return the envelope
		return $messageEnvelope;
	}
1038747
protected function generateMessage($email, $message)
    {
        foreach ($message->getToWithCarriers() as $number) {
            $email->to($this->buildEmail($number, $message));
        }

        if ($message->getAttachImages()) {
            foreach ($message->getAttachImages() as $image) {
                $email->attach($image);
            }
        }

        $email->from($message->getFrom());

        return $email;
    }
817898
public function write($message)
    {
        if (!$this->logFile) {
            throw new \Parable\Log\Exception("No log file set. \Log\Writer\File requires a valid target file.");
        }
        $this->writeToFile($message);
        return $this;
    }
430650
public static function logToFile($message, $level)
    {
        if ($level > self::$config['level']) {
            return;
        }
        
        $filename = self::$config['filename'];
        $template = self::$config['message_template'];
        $tags = array(
            '%date%' => @date('Y-m-d H:i:s'), 
            '%level%' => $level,
            '%message%' => $message
        );
        
        $file = fopen($filename, 'a');
        fwrite($file, str_replace(array_keys($tags), array_values($tags), $template) . "\n");
        fclose($file);
        $file = null;
    }
735665
public function validate(Message $message)
    {
        if ($message->getTitleLength() > self::CHARACTER_LIMIT) {
            $message->addStatus(new SoftLimitTheTitleLengthTo50CharactersStatus());
        }
    }
804429
private function persistHeaders(MessageInterface $message)
    {
        // Headers are excluded from the caching (see RFC 2616:13.5.1)
        static $noCache = array(
            'age' => true,
            'connection' => true,
            'keep-alive' => true,
            'proxy-authenticate' => true,
            'proxy-authorization' => true,
            'te' => true,
            'trailers' => true,
            'transfer-encoding' => true,
            'upgrade' => true,
            'set-cookie' => true,
            'set-cookie2' => true
        );

        // Clone the response to not destroy any necessary headers when caching
        $headers = $message->getHeaders()->getAll();
        $headers = array_diff_key($headers, $noCache);
        // Cast the headers to a string
        $headers = array_map(function ($h) { return (string) $h; }, $headers);

        return $headers;
    }
990567
public function store(OutboxMessage $message)
    {
        $messageId = $message->getMessageId();
        if (isset($this->messages[$messageId])) {
            throw new InvalidArgumentException("Outbox message with ID '$messageId' already exists in storage.");
        }

        $this->messages[$messageId] = new InMemoryStoredMessage($messageId, $message->getTransportOperations());
        $this->lastMessageId = $messageId;
    }
654255
public function send(Message $message, array $emails): int
    {
        $this->connect(); // Establish or revive connection
        $this->command("RSET"); // Reset SMTP buffer

        $this->command(sprintf('MAIL FROM:<%1$s>', $message->sender()->email), null, 250); // Set mail from
        $count = 0;
        foreach ($emails as $email) {
            $this->write(sprintf('RCPT TO:<%1$s>', $email));
            $this->read();
            if ($this->lastResponseCode !== 250) {
                throw SMTPException::invalidRecipient(substr($this->lastResponse, 4));
            }

            $count++;
        }

        $messageMime = $message->compile();
        $messageMimeSize = strlen($messageMime);
        if ($this->options["size"] > 0 && $messageMimeSize > $this->options["size"]) {
            throw SMTPException::exceedsMaximumSize($messageMimeSize, $this->options["size"]);
        }

        $this->command("DATA", null, 354);
        $this->write($messageMime); // Write MIME
        $this->command(".", null, 250); // End DATA

        // Keep alive?
        if (!$this->keepAlive) {
            $this->write("QUIT"); // Send QUIT command
            //unset($this->stream);
            $this->stream = null;  // Close stream resource
        }

        return $count;
    }
727630
public function writer($level, $message)
    {
        (!empty($this->file)) ? $fileName = $this->file : $fileName = '.logs';
        $fileHandling = new FileHandling();
        $text = 'Date/time: '.date('Y-m-d h:i:s A')." , Level: $level , message: ".$message."\n";
        $file = route()->storage->log.$fileName;
        $fileHandling->open($file, 'readWriteAppend')->write($text);
        $fileHandling->close();
    }