5

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
6
  • Can you post the headers of an outgoing mail with wrong domain as sender? It is not exactly clear to me which name/domain you mean.
    – sebix
    Aug 3, 2014 at 9:16
  • Oh, and what's in your /etc/mailname, as you are on debian?
    – sebix
    Aug 3, 2014 at 9:34
  • @sebix my /etc/mailname is mail.mydomain.com. I've added the headers into the body.
    – Mutt
    Aug 3, 2014 at 9:48
  • What happens if you comment out myorigin in main.cf, set /etc/mailname/ to mydomain.com and restart postfix? Additionally: You mention both hostname.mydomain.com and mail.domain.com, can you elaborate on what are the differences and purposes of these two domains?
    – sebix
    Aug 3, 2014 at 10:16
  • 1
    For me the masquerade_domains = $mydomain worked. No flagging as spam. It was easier to fix the cause of the false flagging than the annoying @host.domain.tld.
    – Avamander
    Apr 29, 2017 at 0:07

2 Answers 2

3

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

4

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

1
  • 1
    This works on ubuntu 16.04 however there must be some main.cf variable instead ? anyone ? Sep 14, 2016 at 22:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .