1
sceilig
Problem with xoopsmailer return-path
  • 2006/6/16 6:19

  • sceilig

  • Just popping in

  • Posts: 53

  • Since: 2006/3/1 1


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);
        }

2
Peekay
Re: Problem with xoopsmailer return-path
  • 2006/10/10 13:14

  • Peekay

  • XOOPS is my life!

  • Posts: 2335

  • Since: 2004/11/20


I guess the 'from' field in prefs/mail setup is not populating that variable? I think it gets used to construct a 'from' header in some module notifications. I need to check.

I too would like to have more control over the headers of emails passing through the XOOPS system. Each module seems to differ in the data it sends and I confess I have no idea where to start looking to make any modifications.
A thread is for life. Not just for Christmas.

Login

Who's Online

237 user(s) are online (162 user(s) are browsing Support Forums)


Members: 0


Guests: 237


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits