Codeigniter as an html template for letters

I use the code below to send email from my contact form based on code based code to do this, I use the codes below in my controller,

    $entrydata['name']= $this->input->post('name');
    $entrydata['email']= $this->input->post('email');
    $entrydata['phone']= $this->input->post('phone');
    $entrydata['message']= $this->input->post('message');$msg = 'Email has sent successfully';

            $data['reset'] = TRUE;
            $this->load->library('email');
            $this->email->from(set_value('email'), set_value('name'));
            $this->email->to('my@webs.com');
            $this->email->subject("Get a quote enquiry");
            $all = 'Name:' . set_value('name') ."\n". 'Email :' .' '. set_value('email') ."\n".'Phone :' .' '. set_value('phone') ."\n".'Message :' .' '. set_value('message'); $this->email->message($all);
            $s=$this->email->send();
            $data['message'] = $msg;

Does anyone know how to add a custom email template that will contain information about my contacts?

+5
source share
3 answers

This is an example I made

 $data['map_to']=$this->input->post('map_to');
        $event=$this->db->query("query");
        if($event->num_rows()>0)
        {
            $data['event']=$event->row();
            $data['map_from']=$event->row()->address2;
        }
        else
        {
        $data['event']=NULL;    
        }
      $data['sender_mail'] = 'xx@xx.org';

        $this->load->library('email');
        $config = array (
                  'mailtype' => 'html',
                  'charset'  => 'utf-8',
                  'priority' => '1'
                   );
        $this->email->initialize($config);
        $this->email->from($data['sender_mail'], 'xxxx');
        $this->email->to($mail);
        $this->email->subject('Map Location');
        $message=$this->load->view('map_mail_format',$data,TRUE);
        $this->email->message($message);
        $this->email->send();       

Here I load the view page with the name map_mail_formatand passing the values ​​to this view page ( $data), then assign this view page to a variable, and then send mail with this message

+16
source

first you need to initialize the configuration as

$config['charset'] = 'utf-8';
$config['wordwrap'] = TRUE;
$config['mailtype'] = 'html';
$this->email->initialize($config);

,

$mailbody = $this->load->view('myfile', $data, true);
+5

You can try this

$this->load->helper(array('email'));
$this->load->library(array('email'));
$this->email->set_mailtype("html");
+2
source

All Articles