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.

Any ideas?

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[3910]: 449AF5803F6: to=<tesing@example.com>, relay=smtp.grapevine.com.au[]:25, delay=63275, delays=63274/0.02/0.04/0.4, dsn=4.1.8, status=deferred (host smtp.grapevine.com.au[] said: 450 4.1.8 <benny@server.internal>: 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.

  • Post the relevant log entries and the output of postconf -n.
    – joschi
    May 25, 2010 at 9:01
  • Are you sure that it is not your relay that determine the name of your server by DNS ? Like Joschi, could you give us logs, postconf -n, and maybe mail headers.
    – Dom
    May 25, 2010 at 22:09
  • 1
    Have added log entries where I had problem and postconf -n. May 26, 2010 at 0:43
  • 1
    Yes it is the relay that determine the name of my server, but that postfix isn't using the domain in the configuration but a local domain!! Please see added info above! May 26, 2010 at 0:45
  • I am having the same problem and have not yet been able to fix it: superuser.com/questions/499208/…
    – daveagp
    Nov 3, 2012 at 23:47

2 Answers 2

mydomain = example.com
myorigin = $mydomain

By default, the option append_at_myorigin is set to yes, which means that any and all outgoing mail that has no domain component will get the value of myorigin appended.

In your case, that is the domain name, and not the hostname.

Always send mail using fully-qualified addresses, i.e. containing both a localpart and a valid, existing domain/hostname part.

If for some reason you cannot, use one of the methods described in the Address Rewriting Readme


connect to your server with telnet on port 25, you will see a string that definitively tells you whether or not it's actually using myhostname.

My suspicion is that you simply haven't set address masquerading up properly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.