Skip to content

Instantly share code, notes, and snippets.

@stnight
Created January 24, 2016 23:23
Show Gist options
  • Save stnight/e055f8a1df2b27d09b94 to your computer and use it in GitHub Desktop.
Save stnight/e055f8a1df2b27d09b94 to your computer and use it in GitHub Desktop.
This is a controller, please follow this pattern, it always work for me
<?php
class Sender extends CI_Controller {
public function __construct() // to remember use public
{
parent::__construct();
$this->load->helper('url');
}
public function home() {
$this->load->library('email'); // load email library
$this->email->set_newline("\r\n");
$this->email->from('cictpracticum2015@gmail.com', 'Sample Po');
$this->email->to('earljohn3ric@gmail.com');
$this->email->subject('Sample');
$this->email->attach('/var/www/html/sample.txt');
$message = "Mahal ko si Char and Mahal ako ni Char :D";
$this->email->message($message);
if ($this->email->send()){
echo "Mail Sent!";
} else {
show_error($this->email->print_debugger());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment