public function sendResults(_SimpleEmailForm &$msg, $field, $txtLabel, $fromlabel)
{
// 2012-02-15 db: override unwanted error messages originating from JMail
ob_start();
// Build Body
$msg->subject = (isset($_POST['mod_simpleemailform_subject_' . $this->_instance]))
? htmlspecialchars($_POST['mod_simpleemailform_subject_' . $this->_instance]) : $msg->subject;
$msg->body = $fromlabel . ': ' . htmlspecialchars($msg->from);
for ($x = 1; $x <= 5; $x++) {
$label = 'mod_simpleemailform_field' . $x . '_' . $this->_instance;
$msg->body .= (isset($_POST[$label])) ? "\n" . $field[$x]['label'] . ': ' . htmlspecialchars($_POST[$label]) : '';
}
$msg->body .= (isset($_POST['mod_simpleemailform_textarea_' . $this->_instance]))
? "\n" . $txtLabel . ":\n" . htmlspecialchars($_POST['mod_simpleemailform_textarea_' . $this->_instance]) : '';
// Strip slashes
$msg->body = stripslashes($msg->body);
// Filter for \n in subject - 2010-05-03 DB
$msg->subject = str_replace("\n",'',$msg->subject);
// Send mail
$message = JFactory::getMailer();
//echo $message->dumpLanguage(); exit;
$message->addRecipient($msg->to);
$message->setSender($msg->from);
$message->setSubject($msg->subject);
$message->setBody($msg->body);
// 2012-02-03 DB: added reply to field (has to be array())
if ($msg->cc) { $message->addCC($msg->cc); }
if ($msg->bcc) { $message->addBCC($msg->bcc); }
if ($msg->replyTo) { $message->addReplyTo($msg->replyTo); }
if ($msg->attachment) {
// Formulate FN for attachment
$msg->attachment = $msg->dir . DIRECTORY_SEPARATOR . $msg->attachment;
$message->addAttachment($msg->attachment);
}
try {
if (!$sent = $message->send()) {
throw new Exception($this->_transLang['MOD_SIMPLEEMAILFORM_error']);
}
$msg->copyMe = (isset($_POST['mod_simpleemailform_copyMe_' . $this->_instance]))
? (int) $_POST['mod_simpleemailform_copyMe_' . $this->_instance] : 0;
// 2011-08-12 DB: added option for copyMeAuto
if ($msg->copyMe || $msg->copyMeAuto) {
$message->ClearAllRecipients();
$message->addRecipient($msg->from, $msg-fromName);
if (!$sent = $message->send()) {
throw new Exception($this->_transLang['MOD_SIMPLEEMAILFORM_error']);
}
}
$result = TRUE;
} catch (Exception $e) {
$result = FALSE;
$msg->error = $this->_transLang['MOD_SIMPLEEMAILFORM_error'] . ': Mail Server';
}
// 2012-02-15 db: override unwanted error messages originating from JMail
// 2012-03-07 DB: added test mode
if ($this->_testMode == 'Y') {
$msg->error .= ob_get_contents();
}
ob_end_clean();
return $result;
}