Sunday, 2 February 2020

Email Format Codeigniter


public function addContactCode(){

$from_email = "sunilkalla2011@gmail.com";  // jaha se email send hoga
        $to_email = $this->input->post('email');  // jisko email jana h
       
        $subject = "Alakhpurajharod : Enquiry";

$message = "<h1>Alakhpurajharod : Enquiry</h1>";
$message .= "<b>Name : ".$this->input->post('name')."</b><br/>";
$message .= "<b>Phone: ".$this->input->post('mobile')."</b><br/>";
$message .= "<b>Description : </b><br/>";
$message .= "".$this->input->post('message')."";

$header = "From:".$this->input->post('email')." \r\n";
$header1 = "MIME-Version: 1.0\r\n";
$header2 = "Content-type: text/html\r\n";

        //Load email library
        $this->load->library('email');
        $this->email->from($from_email, 'Identification');
        $this->email->to($to_email);
        $this->email->cc('sunilkalla2011@gmail.com');  // copy email id
        $this->email->cc('in.mukeshsaini@gmail.com');  // copy email id

        $this->email->subject($subject);
        $this->email->message($message);
     

        $this->email->set_header('MIME-Version', '1.0; charset=utf-8');
        $this->email->set_header('Content-type', 'text/html');


        //Send mail
        if($this->email->send()){
            $this->session->set_flashdata("email_sent","<p class='flashmessage'>Email Sent Successfully.</p>");
        }
        else{
            $this->session->set_flashdata("email_sent","<p class='flashmessage'>You have encountered an error</p>");
        }

redirect("home/index/#mail");
     

}



2 ----------------------------------------------------------------

if($data['result']) {
                $_SESSION['CartItem'] = '';
                $this->load->library('email');
                $fromemail="digicardindia2020@gmail.com";
                $toemail = $_POST['email'].",in.mukeshsaini@gmail.com,digicardindia2020@gmail.com";
                $subject = "Digi Card India : ".$_POST['bussiness'];
                $mesg = $this->load->view('front/order_confirm',$data,true);
                $_SESSION['CartItem'] = $mesg;
                $config=array(
                'charset'=>'utf-8',
                'mailtype' => 'html'
                );
                $this->email->initialize($config);
                $this->email->to($toemail);
                $this->email->from($fromemail, "Order Confirmation");
                $this->email->subject($subject);
                $this->email->message($mesg);
                $mail = $this->email->send();
                if($mail) {
                    $this->session->set_flashdata('msg', '<p class="alert alert-success">Thanks for your order.</p>');
                } else {
                   // echo 'not send';exit();
                }
           }

No comments: