[eluser]tkaw220[/eluser]
Hi,
I ran into below situation, and hopefully I could get some helps here.
I have a controller to send out newsletter. I used PHP heredoc to avoid the need to escape string:
Code:
class Newsletter extends CI_Controller {
public function __construct()
{
parent::__construct();
}
public function send()
{
$message = <<<"MESSAGE"
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Title</title>
</head>
<body>
</body>
</html>
MESSAGE;
$config['mailtype'] = 'html';
$this->email->initialize($config);
}
public function another_func()
{
another function here ...
}
} // end controller
1) My first headache: I dislike the indentation of my controller (at the end of the delimiter), how could I make the line indent consistent?
2) Is it possible to exclude the HTML newsletter (the HTML code) from my controller and include it by using PHP include() before calling the CI send email class?
For example:
Code:
private function _get_file()
{
$message = include('../../newsletter.php');
return $message;
}
public function send()
{
$message = $this->_get_file(); // include the HTML code before send
$config['mailtype'] = 'html';
$this->email->initialize($config);
$this->email->from( ...........
}
I include the external markup before the send mail function, but the outcome is an empty email.
I tried to describe my issue as detail as I can. Hopefully I could get some help here.
Thank you.
Regards,
Edwin