That sounds like you are doing something wrong, because
$obj = new StdClass;
$obj->email = 'foo@example.com';
$to = $obj->email;
var_dump($to); // string(15) "foo@example.com"
Note that variables and object members in PHP are case sensitive (unlike functions and methods), so
$to = $obj->eMail;
var_dump($to); // NULL
However, in this case you also receive a PHP Notice
Notice: Undefined property: stdClass::$eMail
It is good practise to enable error_reporting(-1)
and the PHP.ini directives display_errors
and display_startup_errors
on development machines.
Since it's a CW. feel free to use this space for further debugging tips