Why has .localdomain been introduced in Postfix When sending email on my local machine (echo foo | sendmail $USER), the email contains From: (my-user-name)@(my-machine-name).localdomain.

According to my command line tools my host doesn't seem to have a local domain extension added to any of the various host names macOS allows.

$ grep localdomain /etc/hosts
$ grep localdomain /Library/Preferences/SystemConfiguration/preferences.plist
$ scutil --get ComputerName
(my-machine-name)
$ scutil --get HostName
(my-machine-name)
$ scutil --get LocalHostName
(my-machine-name)
$ hostname -f
(my-machine-name)
$ alias hostname
-bash: alias: hostname: not found


My research shows .localdomain stems from a Postfix update. However the Git log contains only generic messages, and I couldn't glean from the HISTORY file why it was added.


Who has introduced .localdomain, and why?
For which specific uses is it applicable, if any? (eg. should it be used email Message-ID?)
There is no email client in your example (besides possibly the echo); sendmail is part of the Mail Transport Agent which on current versions of macOS is by default Postfix. Postfix will set the domain either from the configuration file or failing that some internal value or system call lookup:

$ postconf | grep localdomain
mydomain = localdomain
$ postconf -n | grep "^mydomain"
$ 


This shows that (at least on my system) the mydomain value is localdomain and that that value is not set in /etc/postfix/main.cf. It thus must instead come from an internal value or via some system call. (You could set it to something appropriate in main.cf; many Mail Transport Agents will reject mail from such local domains because spammers, or otherwise score the message as more likely to be spam. This may not be a problem if the email will never reach the Internet.)

$ strings /usr/sbin/postfix | grep localdomain
localdomain
$ cfu 'char buf[254]; gethostname(buf,254); printf("%s\n",buf)'
glide.local
$ 


Shows that postfix could be using localdomain as an internal value, as that string appears in the binary. This is likely given that gethostbyname(3) returns something that is not localdomain on my system (you probably don't have cfu but there are many ways to execute arbitrary system calls). If one downloads the source code for Postfix, there are indeed various references to localdomain:

$ find . -name "*.c" -exec fgrep localdomain {} +
./src/global/mail_addr_find.c:    UPDATE(var_mydomain, "localdomain");
./src/global/mail_addr_find.c:    UPDATE(var_myorigin, "localdomain");
./src/global/mail_addr_find.c:    UPDATE(var_mydest, "localhost.localdomain");
./src/smtp/smtp_map11.c:    UPDATE(var_myhostname, "localhost.localdomain");
./src/smtp/smtp_map11.c:    UPDATE(var_mydomain, "localdomain");
...


So this value is very likely to be set internally by Postfix, and if necessary should be adjusted by editing the configuration.