Here is an example of sending mail on Linux and MacOS, one using sendmail and one using mailx.
The sendmail binary may be both in /usr/sbin/sendmail and the traditional /usr/lib/sendmail but using the /usr/bin/env as a wrapper should work with both location.
Please note that both the envelope header and the from-header must be set. This is done with sendmail both inside the mail and as a command line argument. There are other ways of doing this. But this is one of them.
FROMfirstname.lastname@example.org TOemail@example.com SUBJECT="This is in subject" /usr/bin/env sendmail -f $FROM $TO <<EOF To: $TO From: $FROM Subject: $SUBJECT Hello darkness my old friend! EOF
FROMfirstname.lastname@example.org TOemail@example.com SUBJECT="This is in subject" /usr/bin/mailx -s "$SUBJECT" -r $FROM $TO <<EOF Hello darkness my old friend! EOF