Welcome Guest, Not a member yet? Register   Sign In
send email from HTML template
#1

[eluser]nahalem[/eluser]
Hello,
I have a problem with sending emails via Codeigniter :-). On the bottom I give you whole code what I'm using. I receving blank emails when I'm using this:

controller:

Code:
$config['charset']='utf-8';  
   $config['newline']="\r\n";
   $config['mailtype'] = 'html';

  
   $data = array(
              'blog_title'   => 'My Blog Title',
              'blog_heading' => 'My Blog Heading',
              'blog_entries' => array(
                                      array('title' => 'Title 1', 'body' => 'Body 1'),
                                      array('title' => 'Title 2', 'body' => 'Body 2'),
                                      array('title' => 'Title 3', 'body' => 'Body 3'),
                                      array('title' => 'Title 4', 'body' => 'Body 4'),
                                      array('title' => 'Title 5', 'body' => 'Body 5')
                                      )
$msg =  $this->parser->parse('emails/subscription', $data, TRUE);
$this->load->library('email',$config);
$this->email->from('[email protected]','Forum');  
$this->email->to("[email protected]");  
$this->email->subject('Forum');  
$this->email->message( $msg );
$this->email->send();

emails/subscription VIEW template:
Code:
<html>
<head>
<title>{blog_title}</title>
</head>
<body>

<h3>{blog_heading}</h3>

{blog_entries}
<h5>{title}</h5>
<p>{body}</p>
{/blog_entries}
&lt;/body&gt;
&lt;/html&gt;

I need send email with passing variables to the view and whant to send this template as a body message.

THX
#2

[eluser]InsiteFX[/eluser]
Look at your data array your missing the ); on the end of it.
#3

[eluser]nahalem[/eluser]
nope, I change this array and stil nothing

Code:
$data = array(
              'blog_title'   => 'My Blog Title',
              'blog_heading' => 'My Blog Heading',
              'blog_entries' => 'ff'
            );
   $msg =  $this->parser->parse('emails/subscription', $data, TRUE);
#4

[eluser]CroNiX[/eluser]
Try changing
Code:
$this->load->library('email',$config);
to
Code:
$this->load->library('email');
$this->email->initialize($config);

Also, try checking $msg before sending the email to make sure that got parsed correctly. Looking at your view, blog_entries looks like its supposed to be an array, but you are passing in a string.




Theme © iAndrew 2016 - Forum software by © MyBB