News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Bug with sending e-mail using php mail function.

Started by Kriegel, February 01, 2022, 02:04:05 PM

Previous topic - Next topic

Kriegel

Hi,

I'm running an SMF-forum (v2.0.19) for our (vintage) motorcycle club and noticed some problems with sending e-mails. I noticed the e-mails were sent but the headers with malformed which causes problems with e-mail clients and triggers anti-spam mechanisms. I'm not using SMTP but the PHP mail function to send mails. This functionality is located in Sources/Subs-Posts.php in the sendmail function.

Now line 629 and 630 read this:
        // Line breaks need to be \r\n only in windows or for SMTP.
        $line_break = $context['server']['is_windows'] || !$use_sendmail ? "\r\n" : "\n";

So this means on our Linux platform using sendmail (rather than smtp) the line_break is "\n".
However when I read the manual for the PHP mail function it states that both the headers and messages should be separated by "\r\n", meaning this is incorrect.

I've replaced those Lines simply by:
$line_break = "\r\n";

Now my e-mails are sent out in perfect shape!

I suspect the behavior or definition of the php mail function changed with some version.

Kind regards,
André van Dijk.

Max22

I found out the same line on 2.1, so it could affect that version too.

shawnb61

Address the process rather than the outcome.  Then, the outcome becomes more likely.   - Fripp

Advertisement: