protected function _sendEmail(array $user, array $email, Zend_Mail_Transport_Abstract $transport)
{
if (!$user['email'])
{
return false;
}
$mailObj = new Zend_Mail('utf-8');
$mailObj->setSubject($email['email_title'])
->addTo($user['email'], $user['username'])
->setFrom($email['from_email'], $email['from_name']);
$options = XenForo_Application::get('options');
$bounceEmailAddress = $options->bounceEmailAddress;
if (!$bounceEmailAddress)
{
$bounceEmailAddress = $options->defaultEmailAddress;
}
$mailObj->setReturnPath($bounceEmailAddress);
if ($email['email_format'] == 'html')
{
$replacements = array(
'{name}' => htmlspecialchars($user['username']),
'{email}' => htmlspecialchars($user['email']),
'{id}' => $user['user_id']
);
$email['email_body'] = strtr($email['email_body'], $replacements);
$text = trim(
htmlspecialchars_decode(strip_tags($email['email_body']))
);
$mailObj->setBodyHtml($email['email_body'])
->setBodyText($text);
}
else
{
$replacements = array(
'{name}' => $user['username'],
'{email}' => $user['email'],
'{id}' => $user['user_id']
);
$email['email_body'] = strtr($email['email_body'], $replacements);
$mailObj->setBodyText($email['email_body']);
}
try
{
$mailObj->send($transport);
}
catch (Exception $e)
{
return false;
}
return true;
}