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

8,755

Solution 1

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

Solution 2

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

Share:
8,755

Related videos on Youtube

Mutt
Author by

Mutt

Updated on September 18, 2022

Comments

  • Mutt
    Mutt over 1 year

    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
    
    • sebix
      sebix almost 10 years
      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
      sebix almost 10 years
      Oh, and what's in your /etc/mailname, as you are on debian?
    • Mutt
      Mutt almost 10 years
      @sebix my /etc/mailname is mail.mydomain.com. I've added the headers into the body.
    • sebix
      sebix almost 10 years
      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?
    • Mutt
      Mutt almost 10 years
      @sebix I have no idea why, but changing /etc/mailname from mail.mydomain.com to mydomain.com fixed it! To answer your question hostname.mydomain.com does not have a purpose (or an A record), this is the first machine I have tried to run both a web and mail server on so I didn't want to make the hostname mail like I would've in the past if it was just a mail server. mail.mydomain.com has A and MX records on it. Thank you so much for your help, I spent 6 hours tearing my hair out on this!
    • Avamander
      Avamander about 7 years
      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.
  • Raphaël Ponthieu
    Raphaël Ponthieu over 7 years
    This works on ubuntu 16.04 however there must be some main.cf variable instead ? anyone ?