Created
July 31, 2012 23:49
-
-
Save mpmont/3221791 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// CONTROLLER | |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); | |
class Controllername extends CI_Controller { | |
public function index() | |
{ | |
if (!empty($_POST)) { | |
$this->load->helper('emailsender'); | |
if (contact_email($this->input->post())) { | |
die('your email was sent'); | |
} else { | |
die('there was a problem sending your email'); | |
} | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// HELPER | |
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); | |
if ( ! function_exists('contact_email')) { | |
function contact_email( $data = array()) { | |
//Load the ci instance | |
$CI =& get_instance(); | |
$CI->load->library('email'); | |
$CI->email->from('[email protected]', 'Name'); | |
$CI->email->to($data['email']); | |
$CI->email->subject($data['subject']); | |
$CI->email->message($data['message']); | |
if ($CI->email->send()) { | |
return TRUE; | |
} else { | |
return FALSE; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment