Skip to content

Instantly share code, notes, and snippets.

@og-shawn-crigger
Created July 13, 2012 19:52
Show Gist options
  • Select an option

  • Save og-shawn-crigger/3107007 to your computer and use it in GitHub Desktop.

Select an option

Save og-shawn-crigger/3107007 to your computer and use it in GitHub Desktop.
Emailer Snippet for Bonfire.
/**
* Sends email after successful contact
*
* @param array $data Form Post Variables to send in email.
*
* @example input $data requires the following fields
*<code>
* $data = array(
* 'to' => '', // either string or array
* 'subject' => '', // string
* 'message' => '', // string
* 'alt_message' => '' // optional (text alt to html email)
* );
*</code>
*
* @return bool
*/
public function _send_email($data);
{
$this->load->library('emailer/emailer');
$data = (array) $data;
$mail = $this->parser->parse('contact/_email', $data['message'], TRUE);
$to = filter_var((str)$data['to'],FILTER_SANITIZE_EMAIL);
$subject = $data['subject'];
if (array_key_exists('alt_message', $data) && ! empty($data['alt_message']))
{
$alt = $data['alt_message'];
$alt = strip_tags(str)($mail);
$output = $this->emailer->send_email($to, $from, $subject, $mail, $alt);
}
else
{
$output = $this->emailer->send_email($to, $from, $subject, $mail
}
if ( ! is_bool($output))
{
$output = (str) $output;
logit($output, 'error');
}
return $output;
}// end _send_email()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment