I need to make email notification for my service Written in php. So the question is: Is it correct to use ob_start() and ob_get_clean() or there is a better way?
Simple Example:
<?php
...class logics...
ob_start();
include 'email_html_tpl.php';
$msg = ob_get_clean();
Email::Send('example@example.com', $msg);
?>
Notice that all this happens in script called via ajax.
I am assuming you want to inject variables and/or do some light processing in your email template to generate the actual content.
In that context, it's perfectly fine if you are OK with your email templates being given the power to execute arbitrary code -- this is not an uncommon technique.