0

I've been recently testing Postfix and configuring it as a send-only mail client on our virtual environment. I've been playing around with the settings on a few virtual machines until I got it to work, and I finally found out the proper values I should be putting in. Our configuration is pretty basic, and I'll mask out or domain in code below with what we are using.

# See /usr/share/postfix/main.cf.dist for a commented, more complete version


# Debian specific:  Specifying a file name will cause the first
# line of that file to be used as the name.  The Debian default
# is /etc/mailname.
#myorigin = /etc/mailname

smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no

# appending .domain is the MUA's job.
append_dot_mydomain = no

# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h

readme_directory = no

# TLS parameters
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

# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.

smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
myhostname = mail.example.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = mail.example, localhost.localdomain, localhost
relayhost = smtp-relay.gmail.com
mynetworks = 10.0.0.0/8 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all

The conents of /etc/hostname are below

mail.example.com

The contents of /etc/hosts are below

127.0.0.1   localhost.localdomain localhost
10.x.x.x    mail.example.com    mail

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

The contents of /etc/mailname below

example.com

But for whatever reason, this configuration is the same as another server identical matching up with these files, but when I sent mail from the command line doing something like this:

echo "testing email" | mail -s "test subject" [email protected]

One server has it show that it came from [email protected], and the other shows that it came from [email protected]. I can't for the life of me figure it out, and I'm not sure where and what setting is different between these two servers (I have also since rebooted them and restart the Postfix service several times).

It seems like a system variable or there's another configuration file being polled. I'm really curious and would like to understand what's going on here, and any information would be very helpful. Thank you!

Update 1: Including mail.log comparison and postconf -n

alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
config_directory = /etc/postfix
inet_interfaces = all
inet_protocols = all
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
mydestination = mail.example.com, localhost.localdomain, localhost
myhostname = mail.example.com
mynetworks = 10.0.0.0/8 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
myorigin = /etc/mailname
readme_directory = no
recipient_delimiter = +
relayhost = smtp-relay.gmail.com
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
smtpd_tls_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem
smtpd_tls_key_file = /etc/ssl/private/ssl-cert-snakeoil.key
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtpd_use_tls = yes

Mail.log comparison

  • Mail01: uid=1000 from=<operations>
  • Mail02: uid=1000 [email protected]
  • Mail on mail01 is submitted with a bare username (operations), so postfix appends myorigin making [email protected].
  • Mail on mail02 looks to be submitted with the full email address as the from, so Postfix doesn't append myorigin.

These are both running on Ubuntu 14.04.3 VMs that were created fresh for this, and fully updated. Where would I look to find where this bare username is configured? I checked /etc/passwd but it just says "operations", there must be a file or something I'm missing somewhere - do you have any ideas?

5
  • Please provide the relevant contents from /var/log/mail.log when sending mail from the command line. Maybe there's a clue. Also please add the output of postconf -n instead of the config file above so that we can see what config Postfix is actually using (it might not be what you think it is using).
    – daff
    Oct 5, 2015 at 22:46
  • Try setting myorigin = mydomain.com Oct 6, 2015 at 1:32
  • I made some progress on this, but I'm still stuck figuring this out. Here's the mail.log contents and postconf -n (see updated post). I'm trying to figure out why the operating system is submitting mail with a bare username vs the other one appending the hostname onto the server when it sends mail - there has to be an OS or user account setting that I'm missing somewhere. Oct 7, 2015 at 0:33
  • It seems like one of the servers is using the myorigin file and the other one isn't as well, Ryan. For whatever reason one of them is seeing the user as just bare "username" and the other as "[email protected]" which you can see in my pastebin links above. The one that is just bare "username" is appending the myorigin to it and is working just fine - but the other seems to be using the OS hostname after the username for whatever reason. Oct 7, 2015 at 14:39
  • The closest post that I can find that's similar to the problem I have is here, but it doesn't really explain why that's happening to me. serverfault.com/questions/581235/… Oct 7, 2015 at 16:06

1 Answer 1

1

I figured it out. For whatever reason, it seems like my /etc/mailname wasn't getting processed, even though it was identical to the other server - and the file even had the same MD5sum - the Postfix configuration wasn't taking it. I also noticed that I was using mailutils on one system (the one that wasn't working and had Postfix installed after the fact) and the other was using bsd-mailx. I swapped this before trying the /etc/mailname change, and it didn't seem to make a difference but for what it's worth I'm noting it just in case. Anyways I changed my /etc/mailname to a bogus value like test, then did a sudo postfix reload and sudo service postfix restart and then switched it back to what I intended it to be (contoso.com) followed by the same two commands to refresh the config and service, and lo-and-behold, it was working as intended. Thanks to all that helped.

You must log in to answer this question.

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