CodeIgniter Forums

Full Version: HTML email - Do you see the problem?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Sorry, I do not see what I am doing wrong. Do you see it, could you give me a hint? I might just be too stressed...
I do get the email. But it is not in html.
Tryed to change "sendmail" to 'smtp' and vice versa. Also as different lines for mailtype.


PHP Code:
           $email                        $this->input->post('email');
 
           ...
 
           $config = Array(
 
                       'protocol'  => 'sendmail',
 
                       'smtp_host' => 'smtp.mydomain.com',
 
                       'smtp_port' => 465,
 
                       'smtp_user' => '[email protected]',
 
                       'smtp_pass' => 'password',
 
                       'mailtype'  => 'html'
 
                       'charset'   => 'iso-8859-1',
 
                   );
 
           $this->load->library('email',$config);
 
           $this->email->set_newline("/r/n");
 
           $this->email->from('[email protected]''Jan');
 
           $this->email->to($email);
 
           $this->email->subject('subject');
 
           $body     $this->load->view('report/email.php'$datatrue);
 
           $this->email->message($body);
 
           if($this->email->send()){ successmessage... } 
The View (report/email.php):
Code:
<!DOCTYPE html>
<html>
<head>
   <meta charset="utf-8" />
   <title>your report</title>
   <meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head>
<body>
<div>
   <div>
       </div>
   <p>
       Hello <?=$name?> <!-- this works ! -->
       </p>
   <p>
       Bla bla bla</p>
   <p>&nbsp;</p>
   <p>
       ......................................... <br />
       Signature</p>
   </div>
<div>
   <p><small>and some simple text more</small></p>
   </div>
</body>
</html>
Try this:

PHP Code:
$email $this->input->post('email');

$config = Array(
 
   'protocol'  => 'smtp',
 
   'smtp_host' => 'smtp.mydomain.com',
 
   'smtp_port' => 465,
 
   'smtp_user' => '[email protected]',
 
   'smtp_pass' => 'password',
 
   'mailtype'  => 'html'
 
   'charset'   => 'iso-8859-1',
 
   'crlf'      => "\r\n",
 
   'newline'   => "\r\n",
);

$this->load->library('email'$config);
 
           
$this
->email->from('[email protected]''Jan');
$this->email->to($email);
$this->email->subject('subject');

$body $this->load->view('report/email'$datatrue);

$this->email->message($body);

if (
$this->email->send()){ successmessage... } 

If you send HTML email you must send it as a complete web page. Make sure you don’t have any relative links or relative image paths otherwise they will not work.
Thanks, but it's not that neither.
Tryed to minimize everything in view and around to the core, but no success.
Try send $body to a view and see if it's working.
Thanks! Appreciate your ongoing feedback! 
The view is shown (that way) as it should. 
Maybe it's server side, will google a bit on that.

Code:
public function test()
{
           $data['body']   =   $this->load->view('report/email.php', $data, true);
           $this->load->view('testview',$data);
}
(testview just echo $body)
Hey Jan,

is the debug info given by ...

PHP Code:
$this->email->print_debugger(); 

... telling you anything useful?

-Roger
Thanks for asking!
No, it's empty. Email got send out, but just not as html.

Just had a look in the email details.
"
...
Date: Fri, 30 Sep 2016 08:35:04
From: "my_domain.com" <[email protected]_domain.com>
Reply-To: <[email protected]_domain.com>
X-Sender: [email protected]_domain.com
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <[email protected]_domain.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
... etc
"
So what does the end say of the debug info?

Are you mailing to a gmail account?

You are sending with the charset setting on UTF-8?
(09-30-2016, 12:50 AM)RogerMore Wrote: [ -> ]Huh, empty?!

It should give you a raw view of things as headers and body, and the message if sending the mail was successful or not...

tryed
Code:
if($this->email->send())
           {$_SESSION['successmessage'] =    $this->email->print_debugger(); $this->session->mark_as_flash('successmessage');}
           else{$_SESSION['errormessage'] =    $this->email->print_debugger(); $this->session->mark_as_flash('errormessage');}
           redirect('...my_url...','refresh');
       }
and ...
Code:
if($this->email->send())
           {print_r($this->email->print_debugger()); exit;}
both empty and email is send out (text/plain)
Sorry man, I edited my last post because I didn't see de debug info. I asked the following 3 questions:

So what does the end say of the debug info?

Are you mailing to a gmail account?

You are sending with the charset setting on UTF-8?

Code:
if($this->email->send())
           {print_r($this->email->print_debugger()); exit;}
both empty and email is send out (text/plain)

About the above piece of code... Maybe I am mistaken, normally I'm echoing out $this->email->print_debugger to view de debugger info. I never print_r. Maybe that will explain why you're not seeing normal data.
Oh, when print_debugger is only used when then sending the mail is successful, it will never give you back errors when something is wrong.
Pages: 1 2