Reputation: 777
I'm having a problem with my Mail class. It was working before, but now i'm not sure what happened. here is the error:
Fatal error: Call to undefined method Mail::sendTo() in C:\...\web\modules\register.php on line 30
My mail class:
class Mail
{
public static $Headers = 'From:[email protected]';
public $sendtowho;
public $subject;
public $message;
public $template;
public function sendTo($who='')
{
$this->sendtowho = $who;
}
public function with($subj='',$template)
{
$this->subject = $subj;
$this->template = $template;
}
public function addVars($variables)
{
$TemplateHandler = new Template('mail');
$this->message = $TemplateHandler->renderContent($this->template, $variables);
}
public function send()
{
mail($this->sendtowho, $this->subject, $this->message, self::$Headers);
}
}
My register.php
$mail = new Mail();
$mail->sendTo(User::getMailFromUsername($username));
$mail->with(' Registration Info','registration');
$mail->addVars(array('name' => User::getNameFromUsername($username), 'regKey' => $regKey));
$mail->send();
Line where the error is happening:
$mail->sendTo(User::getMailFromUsername($username));
I'd appreciate any help, thanks!
EDIT: Made some change to names of method and var to, so you can understand it better. BUT STILL GIVING SAME ERROR!!
Upvotes: 0
Views: 55000
Reputation: 777
I fixed the problem. Just need to change the name of my class from Mail to MailInterface. Mail class is already taken by something else. I am using XAMPP with PHP 5.5.
Upvotes: 6