If I write a PHP script to connect to an SMTP server (in my case, this is Postfix installed locally) and send an email, the first "received" header in the e-mail turns out as:
Received: from [SERVER_IP] (SERVER_HOSTNAME [127.0.0.1]) by SERVER_HOSTNAME (Postfix) with ESMTP id D682A34381 for <TO_EMAIL>; Thu, 5 Mar 2009 17:25:18 +0000 (GMT)
This is because the PHP script is being accessed through the browser and Apache is bound to the SERVER_IP.
However, if I execute the same script from the PHP CLI, then the first "received" header is instead:
Received: from localhost.localdomain (SERVER_HOSTNAME [127.0.0.1]) by SERVER_HOSTNAME (Postfix) with ESMTP id AB51934381 for <TO_EMAIL>; Thu, 5 Mar 2009 17:18:01 +0000 (GMT)
This is because the PHP CLI is being called by a regular Linux user (through a cron).
How can I cause the PHP CLI to be bound to the hostname/IP so that when it is called by the user through the cron job, the "received" header shows the server hostname/IP instead of localhost.localdomain?
Note 1: the hostname is correctly set in hostname --fqnd, /etc/hosts, /etc/sysconfig/network and /proc/sys/kernel/hostname
Note 2: I'm using Swift Mailer in PHP, although this is probably irrelevant.