I have a fresh install of postfix on Ubuntu 14.04 server but the test emails I have sent all include the hostname in the email address. I have searched and found quite a few people with the same problem but none of their solutions worked/applied to me. I have tried options from various tutorials but I don't seem to get the same results as they do.

My /etc/postfix/main.cf:

mydomain = example.com    
myorigin = example.com
smtpd_banner = $mydomain ESMTP $mail_name (Ubuntu)
biff = no 
append_dot_mydomain = no
readme_directory = no
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = merlin.example.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination = $myhostname localhost.$mydomain localhost $mydomain
relayhost =
mynetworks = [::ffff:]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all

My /etc/hosts file is:       localhost
XX.XX.XX.XX     merlin.example.com merlin

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

An example received mail header is:

Delivered-To: xxx@gmail.com
Received: by with SMTP id m14csp624755ioo;
Sun, 3 Apr 2016 01:12:36 -0700 (PDT)
X-Received: by with SMTP id fd3mr43641306pab.7.1459671156649;
Sun, 03 Apr 2016 01:12:36 -0700 (PDT)
Return-Path: <user@merlin.example.com>
Received: from merlin.example.com (xxx-89-xx-64.xxx.xxx.xx.xx. [xxx.89.xx.64])
by mx.google.com with ESMTP id n69si18026934pfi.104.2016.
for <xxx@gmail.com>;
Sun, 03 Apr 2016 01:12:36 -0700 (PDT)
Received-SPF: neutral (google.com: xxx.89.xx.64 is neither permitted nor denied by best guess record for domain of user@merlin.example.com) client-ip=xxx.89.xx.64;
Authentication-Results: mx.google.com;
spf=neutral (google.com: xxx.89.xx.64 is neither permitted nor denied by best guess record for domain of user@merlin.example.com) smtp.mailfrom=user@merlin.example.com
Received: by merlin.example.com (Postfix, from userid 1000)
id 02854601326; Sun,  3 Apr 2016 20:12:12 +1200 (NZST)

I can't see what is wrong in my setup and have changed as many options as I can think of based on looking at http://www.postfix.org/. I have restarted postfix after every change.

I would appreciate any suggestions :)

  • 1
    Your example received header does not include the From address, only the MAIL From/Return-Path address, but I'll suppose they are the same. The address is set by the program that is sending the mail, your MUA. How did you send the mail? echo test | mutt -- xxx@gmail.com? – Law29 Apr 3 '16 at 8:55
  • One initial comment from my side would be that after fiddling with oh-so-many options you should go back to a baseline at some point and find out which combination of options gave the desired effect. E-mails seem to be sth trivial but an MTA is not. For the rest I agree with Law29. Configure the email client. – Marki Apr 3 '16 at 11:30
  • Ah ok, I was sending using mail -s "Test subject" xxx@gmail.com. Adding '-aFrom:xxx@example.com' worked - doh! Thanks for your help :) – curlygeek Apr 4 '16 at 8:15

Im not an expert with postfix by any means but I do not see a mydomain directive in your config.

My configs are setup like this:

mydomain = example.com myorigin = $mydomain

  • Oops - cut and paste error - have edited it to show the mydomain setting. Have tried mydomain = /etc/mailname and setting it directly as in the code above. – curlygeek Apr 4 '16 at 8:04

Excerpt from postfix help:

What domain name to use in outbound mail

The myorigin parameter specifies the domain that appears in mail that is posted on this machine. The default is to use the local machine name, $myhostname, which defaults to the name of the machine. Unless you are running a really small site, you probably want to change that into $mydomain, which defaults to the parent domain of the machine name.

For the sake of consistency between sender and recipient addresses, myorigin also specifies the domain name that is appended to an unqualified recipient address.

Examples (specify only one of the following):

    myorigin = $myhostname (default: send mail as "user@$myhostname")
    myorigin = $mydomain   (probably desirable: "user@$mydomain")

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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