<?php
/**
 * Email gönderme işlemlerinde kullanılacak Controller 
 */
class Sendmail extends CI_Controller
{
	
	function __construct()
	{
		parent::__construct();
		//$this->viewFolder = "kullanicilar_v";
		$this->load->model("emailsettings_model");
	}


	public function mailSend ()
	{

		$emailinfo = $this->emailsettings_model->get
		(
			array
			(
				"isactive" => 1
			),	"id DESC","LIMIT 0,1"
		);


		$config = array
		(
            "protocol"  => $emailinfo->protocol,
            "smtp_host" => $emailinfo->host,
            "smtp_port" => $emailinfo->port,
            "smtp_user" => $emailinfo->user,
            "smtp_pass" => $emailinfo->password,
            "starttls"  => true,
            "charset"   => "utf-8",
            "mailtype"  => "html",
            "wordwrap"  => true,
            "newline"   => "\r\n"
        );


        $this->load->library("email", $config);
        $this->email->from($emailinfo->fromm, $emailinfo->username);
        $this->email->to($emailinfo->too);
        $this->email->subject("Mail Denemesi");
        $this->email->message("Deneme Epostası");
        $send = $this->email->send();

        if ($send)
        {
            $alert = array
                (
                	"text"  => "Mail Gönderildi ",
                    "type"  => "success"
                );
        		$this->session->set_flashdata("alert", $alert);
        		redirect(base_url(""));
        }
        else {
            echo $this->email->print_debugger();
        }
	}
}
?>