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?
/var/log/mail.log
when sending mail from the command line. Maybe there's a clue. Also please add the output ofpostconf -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).