Welcome Guest, Not a member yet? Register   Sign In
Sending html email and using static template
#1

Hi guys

I'm sending html mail w/o any trouble, using email library
Now, I'm need to add some design to the "newsletter" system I'm building with CI

Which would be the best location to store images, css, etc. for the email template (relative?, absolute?) to be used within the email library, and how should I do to use and replace variables like {sender_name}, {sender_message} in the view (html template)

Thanks a lot in advance Cool
Reply
#2

I'd just create a view, and then use
PHP Code:
$data['image1'] = 'some_image.jpg';
$this->email->message($this->load->view('view_file'$dataTRUE)); //set the content of the email message to the rendered view 
to send dynamic data to the view and retrieve the rendered view file so you can output it in the email.
Reply
#3

Being an email, the paths should be absolute. For the second problem, look at the great documentation: http://www.codeigniter.com/user_guide/li...email.html
Reply
#4

Thanks guys!
All went fine. I loaded views with third param TRUE, put absolute paths, and all went great.
I had trouble using TTL/SSL but solved by using smtp only, but I guess that's a problem from server
Reply
#5

$body contains the message and required the email-template.

Then you have to load the email library and the follwing to support HTML and send e-mail.
$this->email->set_mailtype("html");
$this->email->initialize($config);

$this->load->library('email');

$this->email->from('[email protected]', 'From Name');
$this->email->to('[email protected]');
$this->email->subject('Subject');
$this->email->message($body);
$this->email->send();

Smile
Rolleyes
Reply




Theme © iAndrew 2016 - Forum software by © MyBB