/**
* Send message
*
* @return boolean
*/
public function send()
{
$result = false;
$errorMessage = null;
if ('' === $this->get('to')) {
$errorMessage = 'Send mail FAILED: sender address is empty';
} elseif (null === $this->mail) {
$errorMessage = 'Send mail FAILED: not initialized inner mailer';
} else {
$this->errorInfo = null;
ob_start();
$this->mail->send();
$error = ob_get_contents();
ob_end_clean();
// Check if there are any error during mail sending
if ($this->mail->isError()) {
$errorMessage = 'Send mail FAILED: ' . $this->prepareErrorMessage($this->mail->ErrorInfo) . PHP_EOL . $this->prepareErrorMessage($error);
$this->errorInfo = $this->mail->ErrorInfo;
} else {
$result = true;
}
}
if ($errorMessage) {
$this->errorMessage = $errorMessage;
\XLite\Logger::getInstance()->log($errorMessage, \LOG_ERR);
}
// Restore layout
if (null !== $this->templatesSkin) {
\XLite\Core\Layout::getInstance()->setSkin($this->templatesSkin);
$this->templatesSkin = null;
}
$this->imageParser->unlinkImages();
return $result;
}