Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eMail issues with PHP mail()... #4734

Closed
exdiogene opened this issue Jul 5, 2023 · 3 comments · Fixed by #4765
Closed

eMail issues with PHP mail()... #4734

exdiogene opened this issue Jul 5, 2023 · 3 comments · Fixed by #4765
Labels
b:1.8 Branch: 1.8.x s:resolved Status: Resolved. Solution implemented or scheduled t:bug Type: Bug. An issue causing error / flaw / malfunction
Milestone

Comments

@exdiogene
Copy link

Because I did not receive any response on the MyBB Community website for 4 days, I am posting the bug here!

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" there is 2 lines causing the problem. The headers lines are not separated with CRLF (\r\n), and because the mailhandler delimiter is changed in the code blocking also the mass mail.

PHP ask for a CRLF (\r\n) separator between headers lines...
This is the section where the headers and delimiter are wrongly changed in the file "/inc/mailhandlers/php.php" :

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

Without the commented lines, this is causing the PHP mail() silent error!

@dvz
Copy link
Member

dvz commented Jul 12, 2023

Looks like it was supposed to address some specific 3rd party problems:

// For some reason sendmail/qmail doesn't like \r\n

Possibly related: php/php-src#8086

@exdiogene
Copy link
Author

If we refer to the PHP Mail() function description it seem preferable to use an Array for data transfer instead of not knowing if it is a CRLF or a LF that should be used in the user hosting environment?

Hoping that PHP would format the mail properly with the Array...

mail

(PHP 4, PHP 5, PHP 7, PHP 8)

mail — Send mail
Description
mail(
string $to,
string $subject,
string $message,
array|string $additional_headers = [],
string $additional_params = ""
): bool

additional_headers (optional)

String or array to be inserted at the end of the email header.

This is typically used to add extra headers (From, Cc, and Bcc). Multiple extra headers should be separated with a CRLF (\r\n). If outside data are used to compose this header, the data should be sanitized so that no unwanted headers could be injected.

If an array is passed, its keys are the header names and its values are the respective header values.

    ...
    ...

    Note:

    If messages are not received, try using a LF (\n) only. Some Unix mail transfer agents (most notably » qmail) replace LF by CRLF automatically (which leads to doubling CR if CRLF is used). This should be a last resort, as it does not comply with » RFC 2822. 

@dvz
Copy link
Member

dvz commented Jul 12, 2023

Yes, one solution may be to split the final string with the used delimiter to pass an array on PHP >= 7.2.0 (when array became an accepted type for the parameter).

@dvz dvz added t:bug Type: Bug. An issue causing error / flaw / malfunction b:1.8 Branch: 1.8.x labels Oct 4, 2023
@dvz dvz added this to the 1.8.37 milestone Oct 5, 2023
@dvz dvz closed this as completed in #4765 Oct 29, 2023
@dvz dvz added the s:resolved Status: Resolved. Solution implemented or scheduled label Oct 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
b:1.8 Branch: 1.8.x s:resolved Status: Resolved. Solution implemented or scheduled t:bug Type: Bug. An issue causing error / flaw / malfunction
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants