Perhaps a phpmailer or OOP expert out there could help me on this one.
Im trying to access the "From" email address from within the mail_send() function for mail being sent using the phpmailer class. But my OOP skills are limited as to how I can get access to it ($this->Sender) - or another variable that holds that email address.
/class/mail/phpmailer/class.phpmailer.php (line 618)
Here's my longwinded reason for why I need access to it.
In sending mail via the xoopsmailer class, I noticed that the return-path in the email header isnt the "From" email address - but defaults to being whatever the server's return-path setting is. Even though return-path is specified in the xoopsmailer send() function, it doesnt get used, on any server Ive used anyway.
i.e.
$this->headers[] = "Return-Path: ".$this->fromEmail;
Instead, you have to "force" the return-path. In the normal php mail() function it would be like this
mail ($to, $subject, $body, $headers, "-f".$fromEmail);
However the class.phpmailer.php file (which xoopsmailer extends) does have the ability to set a -f parameter in the mail_send() function on around line 635. But it can only do this if a From Email Address is available to that function.
I dont think it is in Xoops???
if the $this->Sender field exists, a force return-path parameter will be enforced (conditional on line 14 below). I have confirmed that this doesnt happen and $this-Sender is empty. I could get the sender's email address by parsing the $headers variable but surely there is an easier way of getting at the variable???
function mail_send($header, $body) {
// Cannot add Bcc's to the $to
$to = $this->to[0][0]; // no extra comma
for($i = 1; $i < count($this->to); $i++)
$to .= sprintf(",%s", $this->to[$i][0]);
if ($this->Sender != "" && PHP_VERSION >= "4.0")
{
$old_from = ini_get("sendmail_from");
ini_set("sendmail_from", $this->Sender);
}
if ($this->Sender != "" && PHP_VERSION >= "4.0.5")
{
// The fifth parameter to mail is only available in PHP >= 4.0.5
$params = sprintf("-oi -f %s", $this->Sender);
$rt = @mail($to, $this->encode_header($this->Subject), $body, $header, $params);
}
else
{
$rt = @mail($to, $this->encode_header($this->Subject), $body, $header);
}