On 24/12/2025 05:35, Dan Raymond via Postfix-users wrote:

The sendmail command (ie. /usr/sbin/sendmail) normally extracts the sender's display name from the comment field of /etc/passwd. This is used to populate the "From" header. However, when the -f option is used the /etc/passwd file is not consulted and the display name is instead set to the account name of the current user. This is both incorrect and confusing to the recipient since the display name does not match the sender's account name.

For example:

# whoami
john
# cat /etc/passwd | grep "john"
john:x:1000:1000:John Doe:/home/john:/bin/bash
# echo -e "Subject: test\n\nthis is a test\n" | sendmail [email protected]
# su root
# echo -e "Subject: test\n\nthis is a test\n" | sendmail -f john [email protected]

The resulting emails will have the following "From" headers:

From: John Doe <[email protected]>
From: root <[email protected]>

This also impacts php scripts which use the mail() function to invoke sendmail.


Hi Dan

While this will not address your underlying point, I don't think that your observation is 100% correct in the part where you stated "when the -f option is used the /etc/passwd file is not consulted and the display name isĀ instead set to the account name of the current user."

If you do

cat /etc/passwd | grep "root"

you might find that the "root" that is being used is coming from the comment field of /etc/passwd

John
_______________________________________________
Postfix-users mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to