MyBB Community Forums

Full Version: eMail issues with PHP mail()...
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
MyBB Version 1.8.34
PHP Version 8.0.29
SQL Engine MySQLi 8.0.33

This is a plain english default installation without any plugins.

I was able to find why no email was able to be sent from anywhere in the MyBB forum.

Inside the file "/inc/mailhandlers/php.php" I must delete two variables from the mail() function to allow it to work.

The line :

$sent = @mail($this->to, $this->subject, $this->message, trim($this->headers), $this->additional_parameters);


Was replaced with :

$sent = @mail($this->to, $this->subject, $this->message);


There is something wrong with the content of "$this->headers" .

The variable "$this->additional_parameters" was also used because there is NO safemode variable in the php.ini file.

Hope you can find the issue with the "headers", because from what I got from it, it seem quite OK :

From: "Forums" < *** @ *** .com>
Return-Path: MyBBFR < *** @ *** .support>
Reply-To: MyBBFR < *** @ *** .support>
Message-ID: <afbfe40ee3d3e0de1876bbfefbf90071@www. *** .fr>
Content-Transfer-Encoding: 8bit
X-Priority: 3
X-Mailer: MyBB
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8

All addresses were hidden with " *** "

I have found the problem, the headers lines are not separated with CRLF (\r\n), it seem the mailhandler delimiter is changed somewhere else in the code.

PHP ask for a CRLF (\r\n) separator between those lines...

This is the section where the delimiter is wrongly changed in the file "/inc/mailhandlers/php.php" :


if($this->sendmail)
{
$this->headers = str_replace("\r\n", "\n", $this->headers);
$this->message = str_replace("\r\n", "\n", $this->message);
$this->delimiter = "\n";
}

This is causing the PHP mail() silent error!
I can confirm that the code change fixed the PHP mail issue.

Comment out lines 42 and 44 in inc/mailhandlers/php.php

PHP emails are going through again, including to gmail addresses.
I did not delete the variables $this->headers or $this->additional_parameters as suggested in exdiogene's original post.
+1 for posting in July.
Sadly, I did not see the thread. I'd just about given up on this problem. I thought it was my server configuration.