More to the point, your [font=monospace]Email::sendEmail()[/font] method is static - it can't use [font=monospace]$this[/font] at all. It should be using [font=monospace]self[/font] instead - but it will only be able to access static properties (not the regular properties defined by the constructor, specifically because static methods don't run the constructor).
Two choices - Instantiate the class and make [font=monospace]sendEmail()[/font] a regular, public method:
class Email
{
public function __construct()
{
$this->EmailFrom = "volant@def.com";
$this->EmailTo = "volant@abc.com";
$this->EmailSubject = "i am subject";
$this->EmailBody = "*******";
}
// NOTE: _NO_ "static"!
public function sendEmail()
{
mail ($this->EmailTo, $this->EmailSubject , $this->EmailBody );
}
}
// instantiate an Email object
$Email = new Email();
// call the sendEmail() method
$Email->sendEmail();
or, leave the method static, and make the properties static as well:
class Email
{
public static $EmailFrom = "volant@def.com";
public static $EmailTo = "volant@abc.com";
public static $EmailSubject = "i am subject";
public static $EmailBody = "*******";
public static function sendEmail()
{
mail (self::$EmailTo, self::$EmailSubject , self::$EmailBody );
}
}
// call the static method
Email::sendEmail();
That will solve the Object-Oriented problems you're having, but your mail probably won't be delivered without setting the proper headers - read more on the [man]mail/man function page.
Additionally, I don't see this being terribly useful as-is -- it will only ever send one message, to one recipient. If you are building a wrapper for the mail() function, I'd recommend making it so you can pass parameters (different messages, subjects, and recipients at a minimum) when you call the method.