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.
You can specify the sender's address in sendmail, if you do not then sendmail will populate it with something. That is what is happening, sendmail is guessing and populating the value because you didn't. To solve the problem, tell sendmail what you want the address to be. You send the headers before the message body separated by an empty line in the "data section". Same as when manually sending the email during the SMTP data command. BY COMMAND LINE: sendmail -f [email protected] [email protected] << 'EOF' From: "Pretty Name" <[email protected]> To: [email protected] Subject: Example subject This is the message body. EOF BY COMMAND LINE WITH FILE: /path/email_data.txt From: "Pretty Name" <[email protected]> To: [email protected] Subject: Example subject This is the message body. sendmail -f [email protected] [email protected] < /path/email_data.txt USING PHP: <?PHP ... $cmdLineParams = "-f $from"; $headers = ['From' => $from]; $body = "This is the message body.\n"; mail($to, $subject, $body, $headers, $cmdLineParams); ?> _______________________________________________ Postfix-users mailing list -- [email protected] To unsubscribe send an email to [email protected]
