This should be a simple thing, but I cannot configure postfix to properly send email from a container.
I configure /etc/postfix/main.cf to include the FQDN for the variables, such as:
myhostname = apps.chem.umass.edu
mydestination = $myhostname, apps.chem.umass.edu, localhost.chem.umass.edu, , localhost
And I configure /etc/mailname to be apps.chem.umass.edu.
But doing a simple mail check using the mail utility, the mail server for the university rejects it because it is receiving a domain of “root@apps-chem.lxd”.
I don’t know how to configure the container to not send as apps-chem.lxd and instead send as apps.chem.umass.edu.
Thanks for responding. Given this does not happen on any of our systems that are not containers, I’m very curious about the cause.
Here are the files you requested:
/etc/postfix/main.cf
# 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
# See http://www.postfix.org/COMPATIBILITY_README.html -- default to 2 on
# fresh installs.
compatibility_level = 2
# 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 = apps.chem.umass.edu
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = /etc/mailname
mydestination = $myhostname, apps.chem.umass.edu, localhost.chem.umass.edu, , localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
inet_protocols = all
/etc/hosts:
127.0.0.1 localhost
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
Adding the container IP and hostname+domain name to the container’s /etc/hosts did not fix it. I then added the container IP to the lxd server’s /etc/hosts, and that did not fix it.
I send mail interactively by starting with: mail john@chem.umass.edu
and enter the subject and body when prompted. Works fine for non-container hosts.