PHPMailer from is showing as Root User

Okay, in short:

$email->From = "[email protected]";
$email->FromName = "Support Team";

This worked out for me.


Wrap the whole thing in a try catch. And initialize phpmailer with exceptions enabled

$email = new PHPMailer(true);

It looks like the default values are used. So something goes wrong when calling setFrom(). And it's failing silently because it returns false without exceptions enabled.

try {
  // your mail code here
} catch (phpmailerException $e) {
  echo $e->getMessage();
}

And change the setting of email and from name to:

$email->setFrom($result["emailfrom"], $result["emailfrom"]);

FromName is a property not a method.


class.phpmailer.php file contains the "var $FromName = 'Root User';" section which can be changed to "Desired Name" from "Root User" and have your job done.

Tags:

Php