Welcome Guest, Not a member yet? Register   Sign In
please help me..urgent! send mail problem
#1

[eluser]miss_amylee[/eluser]
i have problem that i really dunno how to solve it. i want to load my template (using template_path) and load it as a view file before send it as mail.the problem now is, it says 'unable to load file .php' which i think its not detect the template path. but if i echo the template path, the path is there. i hv no experience with parse library.hope somebody can help me..im new to CI and sory for my english..here is my controller send.php..

Code:
<?php

class Send extends Controller{
    
    function __construct()
    {
        parent::Controller();
        
        $this->load->library('email');
    }
    
    function index()
    {  
        
      
       $this->load->database();
       $sql = "SELECT * FROM mail WHERE mid = 1001 LIMIT 1";
       $q = $this->db->query($sql);
       if($q->num_rows() == 1)
       {
           $row = $q->row();
           $data = array(
           'nf_editor' => $row->nf_editor,
           'subject' => $row->subject,
           'message' => $row->message,
           'template_id' => $row->template_id
          
           );
        
        $this->db->where('template_id',$template_id);
        $sql = $this->db->get('mail_templates');        
        $template = $sql->row();
              
        //echo $template->template_path;
        //echo base_url().$template->template_path.'email';
        $this->load->library('parser');
        $html = $this->parser->parse($template->template_path, $data);
        
        
        echo $html.'HTML';
        
        
        //$this->load->view('farah/test_view',$data);
       }
        $this->email->clear(); # to clear anything thats already here
        
        $config['mailtype'] = 'html';
        $config['charset'] = 'utf-8';
        
        $this->email->initialize($config);
        
        $this->email->to('[email protected]');
        $this->email->from('[email protected]');
        $this->email->subject($row->subject);
        $this->email->message($html);
                
        $email_sent = $this->email->send();

    }  
    
}


?>
#2

[eluser]theprodigy[/eluser]
Quote:
$data = array(
'nf_editor' => $row->nf_editor,
'subject' => $row->subject,
'message' => $row->message,
'template_id' => $row->template_id
);

$this->db->where('template_id',$template_id);

I don't see where you are setting $template_id. I see where you are setting $data['template_id'], but not $template_id.
#3

[eluser]miss_amylee[/eluser]
oh yes.. big thanx!its working now theprodigy.thanx a lot!can i ask more Q?huhuhu
#4

[eluser]theprodigy[/eluser]
ask away
#5

[eluser]miss_amylee[/eluser]
thx a lot.. i want to make user greetings in this mail.. let say

Hello {amylee};

{message body}

etc.

{amylee} is dynamically from database which means will have queue of name. dis name is not available in

$sql = "SELECT * FROM mail WHERE mid = 1001 LIMIT 1";.. i need to get from other table.. what i am confuse here, should i query to get list of name in same page here? and make pre-define template in my view file for example:

template_a.php

Code:
<p> Dear &lt;?php echo $name ;?&gt;

</p>

<p> &lt;?php echo $msg ;?&gt;
#6

[eluser]theprodigy[/eluser]
Will this user be logged in? Can you set the variable from a session variable?
Code:
$data['name'] = $this->session->userdata('name');
If not, then you will have to pull it from the database in another query.

Do you have a users model? Put a
Code:
get_user_fullname($user_id)
function in there and call that from your function to get the user's name.

What I've done before is keep my emails out of the database. I created an email library with all my pre-written emails, and passed the dynamic data needed to the library. That way, I didn't have to worry about eval()ing anything from the database or writing my own parser, just so I could pass dynamic data into it.




Theme © iAndrew 2016 - Forum software by © MyBB