CodeIgniter Forums
Sending emails using database and template file - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Sending emails using database and template file (/showthread.php?tid=46912)



Sending emails using database and template file - El Forum - 11-20-2011

[eluser]Gukkie[/eluser]
Hi, i am currently confused on how to make this work.

I wanna store my email subject, body in a database, i want to use a common email template to then gather n store the values and then send out the mail, how do i go about doing this?

Right now, i have a registration page so when a user registers successfully, an email gets sent.

Also i have a email_template_view.php file in my views directory.

Here,s my code in the User Controller for now:
Code:
if($this->User_model->register_user_model() == TRUE)
    {
     $this->load->library('email');
     // Send activation email and redirect to success page
     $this->email->clear(TRUE);

     $this->email->to($email);
     $this->email->from('[email protected]', 'My Site');
     $this->email->subject('Activation Link');
     $this->email->message('&lt;html&gt;&lt;body>Activate: <a href="http://www.domain.com/user/account_activation/'.$activationkey.'">Click Here to activate account</a>&lt;/body&gt;&lt;/html>');
    
     if($this->email->send())
     {
      $this->register();
     }
    }

I would greatly appreciate if someone could guide me on how i go about achieving this Smile

Cheers!