I'm trying to send a mail whit PHPmailer but get errors and don't know how to attack this problem. I hope somebody can help me whit this. (in the test phase this set-up works strangely enough)
I got this class which i call. :
class Mailer{
protected $mailer;
public function __construct($mailer) {
$this->mailer = $mailer;
}
public function send($template, $data, $callback){
require_once 'core/init.php';
$message = new Message($this->mailer);
extract($data);
ob_start();
require $template;
$template = ob_get_clean();
ob_end_clean();
$message->body($template);
call_user_func($callback, $message);//callback message
$this->mailer->send();
}
}
Here is the point where i try to mail, and as said before, in the test fase this works whit ob_end_clean.
require 'classes/PHPMailer/PHPMailerAutoload.php';
$mailer = new PHPMailer;
require 'core/mailsettings.php';
$mail = new Mailer($mailer);
$mail->send('mailtemplate/new_bid.php',['name'=>Input::get('name'), 'activation_code' => $randomString1,'servername' => $_SERVER["SERVER_NAME"],'bid' => Input::get('bid'),'bidid' => $bidid, 'email' => Input::get('email')],function($m) {
$m->to(Input::get('email'));
$m->subject('Your input is in progress, please check your mail to activate.');
});Redirect::to('index.php');
But when i try to send the mail I got an error from ob_end_clean.
Notice: ob_end_clean() [ref.outcontrol]: failed to delete buffer. No buffer to delete
even if I try
if (ob_get_length() > 0) { ob_end_clean(); }
as suggested here (failed to delete buffer. No buffer to delete).
Is there something I'm doing wrong in the class Mailer?? Or is there a better way to construct the public function send????
please advice, thank in advanced.