I am trying to set up an outgoing mail server for sending emails which is to relay to our ISP.
In /etc/postfix/main.cf I have myhostname to ourcompany.example.com and myorigin and mydomain to $myhostname. ourcompany.example.com is resolvable.
But looking at the logs in /var/log/maillog it appears that postfix does use the myhostname for the send address, but uses whatever from getmyhostname(), which is set to an internal DNS name since this is an internal server and we only send email out, but not handling incoming email.
EDIT: postconf -n
alias_database = hash:/etc/aliases alias_maps = hash:/etc/aliases command_directory = /usr/sbin config_directory = /etc/postfix daemon_directory = /usr/libexec/postfix data_directory = /var/lib/postfix debug_peer_level = 2 html_directory = no inet_interfaces = localhost inet_protocols = all mail_owner = postfix mailq_path = /usr/bin/mailq.postfix manpage_directory = /usr/share/man mydestination = $myhostname, localhost.$mydomain, localhost mydomain = example.com myhostname = ourcompany.example.com myorigin = $mydomain newaliases_path = /usr/bin/newaliases.postfix queue_directory = /var/spool/postfix readme_directory = /usr/share/doc/postfix-2.6.5/README_FILES relayhost = smtp.grapevine.com.au sample_directory = /usr/share/doc/postfix-2.6.5/samples sendmail_path = /usr/sbin/sendmail.postfix setgid_group = postdrop unknown_local_recipient_reject_code = 550
Where both ourcompany.example.com and example.com are public domains are resolvable by anyone, therefore should be resolvable by my ISP. The problem isn't the domain, but the fact that postfix is not using it, I am getting logs like:
May 26 10:23:22 localhost postfix/smtp: 449AF5803F6: to=<email@example.com>, relay=smtp.grapevine.com.au[188.8.131.52]:25, delay=63275, delays=63274/0.02/0.04/0.4, dsn=4.1.8, status=deferred (host smtp.grapevine.com.au[184.108.40.206] said: 450 4.1.8 <firstname.lastname@example.org>: Sender address rejected: Domain not found (in reply to RCPT TO command))
It is using server.internal instead of $myorigin, and server.internal is what you get from calling gethostname(), and it is an internal hostname and is not resolvable on the public internet.
So my question is this, how do I set postfix to use example.com instead of using gethostname()? My thinking was that gethostname() is only used when I leave myorigin, mydomain and myhostname empty, but setting them to the above setting doesn't do anything.