CodeIgniter Forums
HTML email - Do you see the problem? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: HTML email - Do you see the problem? (/showthread.php?tid=66262)

Pages: 1 2


HTML email - Do you see the problem? - JanFromHamburg - 09-29-2016

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>



RE: HTML email - Do you see the problem? - InsiteFX - 09-29-2016

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.


RE: HTML email - Do you see the problem? - JanFromHamburg - 09-29-2016

Thanks, but it's not that neither.
Tryed to minimize everything in view and around to the core, but no success.


RE: HTML email - Do you see the problem? - InsiteFX - 09-29-2016

Try send $body to a view and see if it's working.


RE: HTML email - Do you see the problem? - JanFromHamburg - 09-29-2016

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)


RE: HTML email - Do you see the problem? - RogerMore - 09-30-2016

Hey Jan,

is the debug info given by ...

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

... telling you anything useful?

-Roger


RE: HTML email - Do you see the problem? - JanFromHamburg - 09-30-2016

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" <noreply@my_domain.com>
Reply-To: <noreply@my_domain.com>
X-Sender: noreply@may_domain.com
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <57ee15ab151f6@my_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
"


RE: HTML email - Do you see the problem? - RogerMore - 09-30-2016

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?


RE: HTML email - Do you see the problem? - JanFromHamburg - 09-30-2016

(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)


RE: HTML email - Do you see the problem? - RogerMore - 09-30-2016

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.