Welcome Guest, Not a member yet? Register   Sign In
Store form data in database and email it to email address x
#7

[eluser]rhand_ci[/eluser]
Just tested sendmail with script I found on CI. I added script to my first controller:
Code:
<?php

class Rentalform extends Controller {
    // Extend controller with new one
    
    function Rentalform()
    {
        parent::Controller();
        $this->load->helper(array('form', 'url')); // load two helpers
        $this->load->library('form_validation'); // load form validation from the library
        $this->load->library('email');
        
    }
    
    function index()
    {
        $data['title'] = "Rental Form";
        $data['heading'] = "Rental Form Heading";
        $this->load->view('rentalform_view', $data);
        $this->load->library('email');
        $config['protocol'] = 'sendmail';  
        $this->email->initialize($config);
        $this->email->from('[email protected]', 'thephpx');
        $this->email->to('[email protected]');
        $this->email->subject('Email Test');
        $this->email->message('Testing the email class.');
        $this->email->send();
        echo $this->email->print_debugger();
    }
    
    function insert_rentalform()
    {
        $this->db->insert('rentalform', $_POST);
        redirect('rentalform');
        
    }
}

And got:

Code:
Your message has been successfully sent using the following protocol: sendmail

User-Agent: CodeIgniter
Date: Fri, 12 Feb 2010 17:39:59 +0300
From: "thephpx"
Return-Path:
To: [email protected]
Subject: =?utf-8?Q?Email_Test?=
Reply-To: "[email protected]"
X-Sender: [email protected]
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <[email protected]>
Mime-Version: 1.0


Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

Testing the email class.

So now I just need to read the $_POST array data and add it to the email body. Still working on that...


Messages In This Thread
Store form data in database and email it to email address x - by El Forum - 02-12-2010, 08:47 AM



Theme © iAndrew 2016 - Forum software by © MyBB