Bug #78916 [Opn]: php-fpm 7.4.0 don't send mail via mail()

From: Date: Thu, 05 Dec 2019 16:05:18 +0000
Subject: Bug #78916 [Opn]: php-fpm 7.4.0 don't send mail via mail()
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-224079@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=78916&edit=1

 ID:                 78916
 User updated by:    ilya at ilya dot pp dot ua
 Reported by:        ilya at ilya dot pp dot ua
 Summary:            php-fpm 7.4.0 don't send mail via mail()
 Status:             Open
 Type:               Bug
 Package:            *Configuration Issues
 Operating System:   systemd/linux
 PHP Version:        7.4.0
 Block user comment: N
 Private report:     N

 New Comment:

<?php
$to_mail = 'user@user.server.com';
$from_mail = 'you@your.server.com';
$from = 'You <'.$from_mail.'>';
$headers =
[
	'MIME-Version' => '1.0',
	'Content-Type' => 'text/html; charset=UTF-8',
	'Content-Transfer-Encoding' => 'binary',
	'From' => $from,
	'Reply-To' => $from,
];
mail($to_mail, 'Test message', <p>Test message.</p>, $headers,
'-f'.$from_mail);
?>


Previous Comments:
------------------------------------------------------------------------
[2019-12-05 16:05:13] ilya at ilya dot pp dot ua

<?php
$to_mail = 'user@user.server.com';
$from_mail = 'you@your.server.com';
$from = 'You <'.$from_mail.'>';
$headers =
[
	'MIME-Version' => '1.0',
	'Content-Type' => 'text/html; charset=UTF-8',
	'Content-Transfer-Encoding' => 'binary',
	'From' => $from,
	'Reply-To' => $from,
];
mail($to_mail, 'Test message', <p>Test message.</p>, $headers,
'-f'.$from_mail);
?>

------------------------------------------------------------------------
[2019-12-05 14:58:52] retertertert at fgfgfg dot com

> To properly diagnose the problem, we need a short 
> but complete example script to be able to reproduce
> this bug ourselves

this is sonsense 

obviously the namespace/capabilities options used in the systemd unit are killing the communiction
of the postfix processes runnin on hebalv the server, that's how sendmail prcoess works, it
opens other postfix related processes which need capabilities

this sounds more than RestrictAddressFamilies is also used now and "AF_UNIX AF_NETLINK" is
missing, without a spamass-milter can't send BCC mails too

RestrictAddressFamilies=AF_INET AF_INET6 AF_LOCAL AF_UNIX AF_NETLINK

------------------------------------------------------------------------
[2019-12-05 14:37:21] sjon@php.net

Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves.

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external
resources such as databases, etc. If the script requires a
database to demonstrate the issue, please make sure it creates
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.

I run php-fpm using the same version and CapabilityBoundingSet and mail works fine - so we need more
details.

Since the error is logged by postfix I don't think this is caused by php-fpm, who provides
/usr/bin/sendmail on this machine?

------------------------------------------------------------------------
[2019-12-05 14:23:23] ilya at ilya dot pp dot ua

Description:
------------
After update to 7.4.0 php-fpm don't send mail via mail()/
In postfix mail log: fatal: inet_addr_local[getifaddrs]: getifaddrs: Address family not supported by
protocol
nginx log empty.

php-fpm.service
CapabilityBoundingSet=CAP_CHOWN CAP_SETGID CAP_SETUID

What else needs to be added here so php can send mail again?

Test script:
---------------
protected static function mail($to,$subject,$body)
	{
		$from = escape(CONFIG['mail']['name']).'
<'.CONFIG['mail']['mail'].'>';
		$headers =
		[
			'MIME-Version' => '1.0',
			'Content-Type' => 'text/html; charset=UTF-8',
			'Content-Transfer-Encoding' => 'binary',
			'From' => $from,
			'Reply-To' => $from,
		];
		return mail($to, $subject, $body, $headers,
'-f'.CONFIG['mail']['mail']);
	}

Expected result:
----------------
Send mail

Actual result:
--------------
fatal: inet_addr_local[getifaddrs]: getifaddrs: Address family not supported by protocol


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=78916&edit=1


Thread (14 messages)

« previous php.bugs (#224079) next »