Changing mail sending from command line from mail(x) to s-nail

Problem

It seems that the default email client in Fedora 40 is s-nail instead of mailx in Fedora 39, and trying to send an email from the command line does not work anymore.

Solution

The two changes required in order for the command to work with s-nail are:

  • Use spaces instead of commas in the recipients, and/or in the cc_recipients lists
  • When you use attachments (-a flag) and cc_recipients (-c flag), the -a flag should be before the -c flag, otherwise:
s-nail: -a is an invalid alias name

So the full command can be like the following:

echo $body | mail -s "Reports for $yesterday" -a $report_path_a -a $report_path_b -c $cc_recipients $recipients