Postfix - hostname appearing in email address

5,417

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):

/etc/postfix/main.cf:
    myorigin = $myhostname (default: send mail as "user@$myhostname")
    myorigin = $mydomain   (probably desirable: "user@$mydomain")
Share:
5,417

Related videos on Youtube

curlygeek
Author by

curlygeek

Updated on September 18, 2022

Comments

  • curlygeek
    curlygeek almost 2 years

    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_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
    smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
    smtpd_use_tls=yes
    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 = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
    mailbox_size_limit = 0
    recipient_delimiter = +
    inet_interfaces = all
    inet_protocols = all
    

    My /etc/hosts file is:

    127.0.0.1       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: [email protected]
    Received: by 10.107.173.142 with SMTP id m14csp624755ioo;
    Sun, 3 Apr 2016 01:12:36 -0700 (PDT)
    X-Received: by 10.66.101.35 with SMTP id fd3mr43641306pab.7.1459671156649;
    Sun, 03 Apr 2016 01:12:36 -0700 (PDT)
    Return-Path: <[email protected]>
    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.04.03.01.12.36
    for <[email protected]>;
    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 [email protected]) 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 [email protected]) [email protected]
    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 :)

    • Law29
      Law29 about 8 years
      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 -- [email protected]?
    • Kishan K
      Kishan K about 8 years
      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.
  • curlygeek
    curlygeek about 8 years
    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.