get('senderemail');
// create a lookup with all the injectable tags
$placeholders = [
'recipient' => $name ?: $email,
'sender' => $message->getSenderName(),
'message' => (string) $message->getMessage(),
'context' => $message->getContext()->getSubject(),
'url' => $message->getContext()->getUrl(),
];
if (strlen($placeholders['message']) === 0) {
// message without content, only attachments added
$placeholders['message'] = '' . JText::translate('VBO_CHAT_MESSAGE_MAIL_NOTIFICATION_NOCONT') . '';
}
// create e-mail subject
$subject = JText::translate('VBO_CHAT_MESSAGE_MAIL_NOTIFICATION_SUBJECT');
// create e-mail body
$body = JText::translate('VBO_CHAT_MESSAGE_MAIL_NOTIFICATION_BODY');
// inject placeholders to both the subject and body
foreach ([&$subject, &$body] as &$str) {
// iterate all tags
foreach ($placeholders as $tagName => $tagValue) {
// inject tag within the template
$str = str_ireplace('{' . $tagName . '}', $tagValue, $str);
}
}
// init mail data wrapper
$mail = VBOMailWrapper::getInstance()
->setSender($senderMail, $message->getSenderName())
->setRecipient($email)
->setReply($senderMail)
->setSubject($subject)
->setContent($body);
foreach ($message->getAttachments() as $attachment) {
$mail->addAttachment($attachment->getPath());
}
if ($mail->isHtml()) {
// replace new lines with
tags
$mail->setContent(nl2br($mail->getContent()));
}
try {
// send e-mail through the current platform service
$result = VBOFactory::getPlatform()->getMailer()->send($mail);
} catch (Exception $error) {
// silently catch the error
$result = false;
}
return $result;
}
}