I've had the same sendmail setup for YEARS with no problems, but I recently noticed that some of my generated emails weren't being delivered. I specifically saw that they weren't being delivered to Gmail because I have all of my emails directed to Gmail, but it could have also been affecting other email providers, too.
It took about 4 days of digging to figure out the problem.
When using sendmail, it's required to have an email address in the From: field; eg:
In my scripts I never forced a return email address; I plugged it in if provided by the user, but if not then the system always plugged in my_server_account@my_server_name.com.
But apparently this is no longer acceptable. I stumbled across this error in my server's delivery report:
ECDHE-RSA-AES128-GCM-SHA256:128 CV=yes: SMTP error from remote mail server after end of data: 550-5.7.1 [220.127.116.11 14] Messages missing a valid address in From:\n550 5.7.1 header, or having no From: header, are not accepted. k8si721600qtj.365 - gsmtp
(where 18.104.22.168 represents my server's IP)
The solution was to simply force a From: email address in all of my scripts. I also used the -f flag, like so:
# Perl (not sure if -tif is the same as -ti -f?
open (MAIL,"|$mailprog -ti -f "example\@example.com");
print MAIL <<EOF;
From: CSDude <example\@example.com>
Subject: the subject
blah blah blah
$to = 'firstname.lastname@example.org';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: CSDude <email@example.com>' . "\r\n" .
'Reply-To: firstname.lastname@example.org' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers, '-f email@example.com');
And since we're talking about it, here are all of the -options for sendmail: