Welcome Guest, Not a member yet? Register   Sign In
HTML email - Do you see the problem?
#1

(This post was last modified: 09-29-2016, 11:22 AM by JanFromHamburg.)

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>
Reply
#2

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.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

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

Try send $body to a view and see if it's working.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#5

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)
Reply
#6

Hey Jan,

is the debug info given by ...

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

... telling you anything useful?

-Roger
Reply
#7

(This post was last modified: 09-30-2016, 12:45 AM by JanFromHamburg.)

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
"
Reply
#8

(This post was last modified: 09-30-2016, 12:58 AM by RogerMore.)

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?
Reply
#9

(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)
Reply
#10

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.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB