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:
CSDude <example@example.com>
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 [123.45.67.89 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 123.45.67.89 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;
To: to\@example.com
From: CSDude <example\@example.com>
Subject: the subject
blah blah blah
EOF;
close (MAIL);
# PHP
$to = 'to@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: CSDude <example@example.com>' . "\r\n" .
'Reply-To: example@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers, '-f example@example.com');
And since we're talking about it, here are all of the -options for sendmail:
[
commandlinux.com...]