Sending emails fail with FastCGI/nginx

I followed instructions to set up RT FastCGI service for use with nginx on AlmaLinux 9.2, but sending emails fail with error message:

[30649] [Thu May 25 18:20:46 2023] [critical]: <rt-5.0.4-30649-1685038846-390.444411-727-0@somedomain>: Could not send mail with command `/usr/sbin/sendmail -oi -t -ODeliveryMode=b -OErrorMode=m -f some@email.com`: program unexpectedly closed pipe at /opt/rt5/sbin/../local/lib/RT/Interface/Email.pm line 940.

Stack:
  [/opt/rt5/sbin/../local/lib/RT/Interface/Email.pm:940]
  [/usr/share/perl5/IPC/Open3.pm:254]
  [/usr/share/perl5/IPC/Open2.pm:121]
  [/opt/rt5/sbin/../local/lib/RT/Interface/Email.pm:944]
  [/opt/rt5/sbin/../local/lib/RT/Action/SendEmail.pm:300]
  [/opt/rt5/sbin/../local/lib/RT/Action/SendEmail.pm:115]
  [/opt/rt5/sbin/../lib/RT/ScripAction.pm:201]
  [/opt/rt5/sbin/../lib/RT/Scrip.pm:665]
  [/opt/rt5/sbin/../lib/RT/Scrips.pm:297]
  [/opt/rt5/sbin/../lib/RT/Transaction.pm:213]
  [/opt/rt5/sbin/../lib/RT/Record.pm:1692]
  [/opt/rt5/sbin/../local/lib/RT/Ticket.pm:612]
  [/opt/rt5/sbin/../lib/RT/Interface/Email/Action/Defaults.pm:106]
  [/opt/rt5/sbin/../lib/RT/Interface/Email/Action/Defaults.pm:135]
  [/opt/rt5/sbin/../lib/RT/Interface/Email/Action/Defaults.pm:121]
  [/opt/rt5/sbin/../local/lib/RT/Interface/Email.pm:429]
  [/opt/rt5/sbin/../local/lib/RT/Interface/Email.pm:258]
  [/opt/rt5/share/html/REST/1.0/NoAuth/mail-gateway:61] (/opt/rt5/sbin/../local/lib/RT/Interface/Email.pm:961)

Processes look like this:

rt         30645  0.1  0.0   5344  1612 ?        Ss   20:20   0:00 /usr/bin/multiwatch --forks=3 --signal=TERM -- /opt/rt5/sbin/rt-server.fcgi
rt         30647 51.1  4.0 182252 164028 ?       S    20:20   0:04  \_ /usr/bin/perl -w /opt/rt5/sbin/rt-server.fcgi
rt         30648 50.1  4.0 182248 163940 ?       S    20:20   0:04  \_ /usr/bin/perl -w /opt/rt5/sbin/rt-server.fcgi
rt         30649 55.3  4.1 185360 167116 ?       S    20:20   0:04  \_ /usr/bin/perl -w /opt/rt5/sbin/rt-server.fcgi
rt         30687  0.0  0.1  38088  5528 ?        S    20:20   0:00      \_ /usr/sbin/sendmail -oi -t -ODeliveryMode=b -OErrorMode=m -f some@email.com
rt         30688  0.0  0.1  38084  5548 ?        S    20:20   0:00      |   \_ /usr/sbin/postdrop -r

Postfix does not report any errors in /var/log/maillog

Tried Msmtp, but it’s the same.

Then created /etc/systemd/system/rt.service and used it instead of rt-server.service and rt-server.socket:

[Unit]
Description=FastCGI spawner for RT5
After=syslog.target

[Service]
Type=forking
PIDFile=/var/run/%p.pid
SyslogIdentifier=%p
Environment=WORKERS=3
EnvironmentFile=-/etc/default/%p
ExecStart=/usr/bin/spawn-fcgi \
    -F ${WORKERS} \
    -d / \
    -u rt \
    -g rt \
    -P /var/run/%p.pid \
    -p 5000 \
    -- /opt/rt5/sbin/rt-server.fcgi
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target

With that everything works fine.

What could be the problem?