Postfix sends as hostname.domain.com instead of domain.com

I've been trying to set up a debian mail server running postfix, but when I try to send mail via mail [email protected] the recipient sees the sender as hostname.domain.com. The hostname it sends does not have an A or MX record set up to it, it is just the /etc/hostname. I can manually set the sender to [email protected] if I send by logging in via telnet localhost 25.

my main.cf

myorigin = mydomian.com
myhostname = mail.mydomain.com
mydestination = mail.mydomain.com, mydomain.com, localhost, localhost.localdomain
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases

smtpd_tls_cert_file=/etc/ssl/certs/mailcert.pem
smtpd_tls_key_file=/etc/ssl/private/mail.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_tls_security_level=may
smtpd_tls_protocols = !SSLv2, !SSLv3
local_recipient_maps = proxy:unix:passwd.byname $alias_maps

and mail.log when I send out an email

Aug  3 06:28:51 hostname postfix/pickup[7047]: 4D5432023A: uid=1000 from=<user@hostname>
Aug  3 06:28:51 hostname postfix/cleanup[7065]: 4D5432023A: message-id=<[email protected]>
Aug  3 06:28:51 hostname postfix/qmgr[7048]: 4D5432023A: from=<[email protected]>, size=339, nrcpt=1 (queue active)
Aug  3 06:28:52 hostname postfix/smtp[7067]: 4D5432023A: to=<[email protected]>, relay=mail.destinationserver.com[IP]:25, delay=1.4, delays=0.11/0.01/0.49/0.78, dsn=2.0.0, status=sent (250 Queued (0.110 seconds))
Aug  3 06:28:52 hostname postfix/qmgr[7048]: 4D5432023A: removed

I've tried setting masquerade_domains = mydomain.com but it gets flagged as spam in thunderbird and gmail when I do this.

Headers from a message sent by my server:

    Return-Path: [email protected]
Received: from mail.mydomain.com (DESTINATION [127.0.0.1])
    by mail.destination.com
    ; Sun, 3 Aug 2014 08:10:06 +0200
Received: by mail.mydomain.com (Postfix, from userid 1000)
    id 6D7A68033A; Sun,  3 Aug 2014 08:10:27 +0200 (CEST)
To: <[email protected]>
Subject: test
X-Mailer: mail (GNU Mailutils 2.99.97)
Message-Id: <[email protected]>
Date: Sun,  3 Aug 2014 08:10:27 +0200 (CEST)
From: [email protected]

fdsa

On debian, the default sender's domain used is specified by /etc/mailname. AFAIK this is a Debian specific modification to postfix.

So it should be solved by filling /etc/mailname with mydomain.com. And myorigin in postfix defaults to /etc/mailname on debian, which also should be used in my opinion (so just delete this line).


I'm on Ubuntu 14.04 and I have exactly the same symptom as yours. But my problem is resolved by specifying a "From:" header explicitly, e.g.

mail -aFrom:[email protected] ...

If the -a option is missed in above command, there will be the exact symptom as yours.

BTW, I use mailutils version 1:2.99.98-1.1 amd64