Topic: php8 and emailing PSA
Hi Folks,
This week I upgraded my debian server so that now it has php8.1. Today I was going to do bookkeeping, but when I tried to email an invoice to a gmail address, I got a bounce back like this one:
Remote host said: 550-5.7.1 [69.60.111.174] Messages with multiple addresses in From: header are
550 5.7.1 not accepted. bs14-20020a05620a470e00b006a6c64ef202si3081371qkb.698 - gsmtp
So I instead ended up spending most of my afternoon tracking down the solution to this problem. As far as I can tell, this bounce only comes from gmail, I wasn't able to reproduce this issue with any microsoft-hosted accounts, or with any other email servers I sent test messages to.
It appears that php8(.1) has changed the way it handles line feeds, which is the source of the problem. The fix, or at least the one that worked for me, was to modify the following line in my php.ini file thusly:
sendmail_path = "/usr/bin/dos2unix -u|/usr/sbin/sendmail -t -i"
And of course make sure you have dos2unix installed
Hopefully this saves someone some time.
After traversing many dead-end rabbit holes, the answer was found here:
https://github.com/php/php-src/issues/8086
Many thanks to hansherlighed for the insight and solution.