PHPList fails for email addresses with leading, trailing, or multiple adjacent dots

StackOverflow https://stackoverflow.com/questions/9167081

  •  26-04-2021
  •  | 
  •  

Pregunta

PHPList (version 2.10.17) fails to send messages to addresses that match one of the following formats:

my..Name@domain.com
myName.@domain.com
.myName@domain.com

the error message is Could not instantiate mail function. The code in question is:

function MailSend($header, $body) {
    $to = "";
    for($i = 0; $i < count($this->to); $i++)
    {
        if($i != 0) { $to .= ", "; }
        $to .= $this->to[$i][0];
    }

    if ($this->Sender != "" && (bool) ini_get("safe_mode") === FALSE)
    {
        $old_from = ini_get("sendmail_from");
        ini_set("sendmail_from", $this->Sender);
        $params = sprintf("-oi -f %s", $this->Sender);
        $rt = @mail($to, $this->EncodeHeader($this->Subject), $body,
                    $header, $params);
    }
    else
        $rt = @mail($to, $this->EncodeHeader($this->Subject), $body, $header);

    if (isset($old_from))
        ini_set("sendmail_from", $old_from);

    if(!$rt)
    {
        $this->SetError($this->Lang("instantiate"));
        return false;
    }

    return true;
}

The chosen code path is:

   else
      $rt = @mail($to, $this->EncodeHeader($this->Subject), $body, $header);

I could not reproduce this error on my own webserver where I set up PHPList for testing purposes.
Unfortunately the only system that is showing this behaviour is the production system. To add to that, I don't have access to any logfiles on that system - so I don't really know what is wrong.
My best guess is, that some sort of "string escape" on $to is needed to make this work, but I am somewhat reluctant to tamper with a production system (other than inserting some logging output).

Does anyone know a workaround for this sort of problem?

¿Fue útil?

Solución

This is not an error, it is expected behavior. The local-part of an email address (the part before the @) may contain ., provided it is not the first nor the last character, and provided also that it does not appear two or more times consecutively. This means all three examples are invalid email addresses.

Read more about valid email addresses.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top