Send an email using the specified content, template and layout

@param string|array|null $content String with message or array with messages
@return array
@throws \BadMethodCallException
199739
public function send($content = null)
    {
        if (empty($this->_from)) {
            throw new BadMethodCallException('From is not specified.');
        }
        if (empty($this->_to) && empty($this->_cc) && empty($this->_bcc)) {
            throw new BadMethodCallException('You need specify one destination on to, cc or bcc.');
        }

        if (is_array($content)) {
            $content = implode("\n", $content) . "\n";
        }

        $this->_message = $this->_render($this->_wrap($content));

        $transport = $this->getTransport();
        if (!$transport) {
            $msg = 'Cannot send email, transport was not defined. Did you call transport() or define ' .
                ' a transport in the set profile?';
            throw new BadMethodCallException($msg);
        }
        $contents = $transport->send($this);
        $this->_logDelivery($contents);

        return $contents;
    }
658516
protected function ajaxContent($content)
    {
        $message = null;

        $this->header('Content-Type', 'application/json');

        if ($content instanceof Arrayable) {
            $content = $content->toArray();
        } elseif (is_string($content)) {
            $content = ['content' => $content];
        } elseif (!is_array($content) && !$content instanceof \Exception) {
            return $this->ajaxContent(new \Exception("No valid content has been submitted!", BaseResponse::HTTP_BAD_REQUEST));
        } elseif ($content instanceof \Exception) {

            $this->setStatusCode($content->getCode() < 300 ? BaseResponse::HTTP_BAD_REQUEST : $content->getCode());

            $message = $content->getMessage();

            if ($content instanceof MbException) {
                $content = $content->getMessages();
            } else {
                $content = null;
            }
        }

        $this->original = [
            'meta' => [
                'code'    => $this->getStatusCode(),
                'message' => $message,
            ],
            'data' => $content,
        ];

        $this->getMbAudit()->setResponseType('ajax');
        $this->getMbAudit()->setResponseData($this->original);

        return $this->original;
    }
42727
public function setContent($content)
    {
        $this->content = null;
        if ($content === null) {
            return;
        }

        if (TypeHandling::isSimpleType(gettype($content)) && !is_array($content)) {
            $this->content = (string)$content;
        }

        if (is_resource($content)) {
            $this->content = $content;
        }

        return $this;
    }
870022
public function setContent(string $content = null): ResponseContextAbstract
    {
        if (is_null($content)) {
            return $this;
        }

        $this->assertIsValid($content);

        $this->content = $content;

        return $this;
    }
813132
private function sendEmail(OutputInterface $output, $content)
    {
        $output->writeln("Sending an email");
        $transport = $this->getTransport();
        $mailer    = \Swift_Mailer::newInstance($transport);

        $message = \Swift_Message::newInstance('Bldr Notify - New Message')
            ->setFrom(['no-reply@bldr.io' => 'Bldr'])
            ->setTo($this->getEmails())
            ->setBody(
                "<p>Bldr has a new message for you from the most recent build</p>\n<br /><pre>{$content}</pre>\n",
                "text/html"
            )
            ->addPart($content, 'text/plain')
        ;

        $result = $mailer->send($message);

        return $result;
    }
1343176
private function recursivelyArrayify($content = null)
        {
            $return = [];
            if (false === $content || null === $content) {
                return;
            } else if ($content instanceof Element) {
                $return[] = $content->toArray();
            } else if (!is_array($content)) {
                $return[] = $content;
            } else {
                foreach ($content as $element) {
                    $return[] = $this->recursivelyArrayify($element);
                }
            }
            return $return;
        }
674502
private function recursivelyStringify($content = null)
        {
            $return = [];
            if (false === $content || null === $content) {
                return;
            } else if (!is_array($content)) {
                $return[] = $content;
            } else {
                foreach ($content as $element) {
                    $return[] = $this->recursivelyStringify($element);
                }
            }
            return implode('', $return);
        }
82407
private function createJavascriptResponse($content)
    {
        $rf = $this->app->make(ResponseFactoryInterface::class);

        return $rf->create(
            $content,
            200,
            [
                'Content-Type' => 'application/javascript; charset=' . APP_CHARSET,
                'Content-Length' => strlen($content),
            ]
        );
    }
948327
public function prepend($content = null)
        {
            if (null === $content) {
                return;
            } else if (is_array($content)) {
                foreach (array_reverse($content) as $row) {
                    array_unshift($this->content, $row);
                }
            } else {
                array_unshift($this->content, $content);
            }
            return $this;
        }
961785
public function arrayToJson($content = null)
    {
        if ($this->getJsonEncodeArray() && is_array($content)) {
            $this->header('Content-Type: application/json');
            return json_encode($content);
        }

        return $content;
    }
76217
public function prepare($content = null)
    {
        is_null($content) || $this->setContent($content);

        $content = $this->getContent();

        $content = $this->arrayToJson($content);

        $content = $this->objectToJson($content);

        $content = $this->printRecursiveNonAlphaNum($content);

        if (! $this->jsonErrors($content)) {
            $this->header('Content-Type: application/json');
        }

        $this->setContent($content);

        return $this;
    }
828626
public function send($content = null) {
		if ($this->sent) {
			return $this;
		}

		if ($this->request->isMethod('HEAD')) {
			$this->setMode(self::MODE_STRING);
			$this->unsetHeader('Content-Length');
			$this->setBody('');
		}

		switch ($this->mode) {
		case self::MODE_STRING:
			if ($content !== null) {
				$this->setBody($content);
			}
			break;

		case self::MODE_FILE:
			if (is_file($content)) {
				if (!$this->hasHeader('Content-Type')) {
					$this->setHeader('Content-Type', 'application/octet-stream ');
				}
				$this->setHeader('Content-Length', filesize($content));
				$this->setBody($content);
			} else {
				$this->setMode(self::MODE_STRING);
				$this->setStatusCode(404);
				$this->unsetHeader('Content-Length');
				$this->setBody('');
			}
			break;

		case self::MODE_STREAM:
			$this->setBody($content);
			break;
		}

		$this->sendHeaders();

		$this->sendBody();

		switch ($this->mode) {
		case self::MODE_STRING:
		case self::MODE_FILE:
			$this->end();
			break;
		}

		return $this;
	}
1009725
public function writeContent(array $content)
    {
        if (!$this->canWrite()) {
            throw new Exception("Unable to write file {this->file}.");
        }
        
        $json = $this->jsonEncode($content);
        
        return $this->writeFileContent($this->file, $json);
    }
791732
public function handle(?string $content = null, array $atts = []): string
    {
        if (is_null($this->callback)) {
            return (string) $content;
        }
        $callback = $this->callback->bindTo($this, $this);

        return $callback($content, $atts);
    }
1262860
private function setContent($content)
    {
        if (is_array($content))
            $this->content = $content;
        elseif (is_string($content))
            $this->content = trim($content);

        return $this;
    }
1238217
private function replaceIndexTemplateContents($content)
    {
        /* Index View Page */
        //replace table headers - <th> {%tableColumns%}</th>
        //replace table td - {%controllerColumns%}

        $content = str_replace('#controllerName#', $this->controller, $content);
        $content = str_replace('#ControllerName#', Inflector::classify($this->controller), $content);
        $content = str_replace('{%primaryKey%}',
            $this->command->table()->getPrimaryKey(),
            $content
        );

        $column = '';

        $column = $this->replaceTableElements('th');
        $content = str_replace('{#thColumns#}', $column.PHP_EOL, $content);

        $column = $this->replaceTableElements('td');
        $content = str_replace('{#tdColumns#}', $column.PHP_EOL, $content);

        return $content;
    }
602774
public static function table(
        string $content = null, 
        array $attributes = []
    ) : string
    {
        return self::tag("table", $content, $attributes);
    }