I am unsure if this post belongs here or on Server Fault as I cannot say for sure if this is a Magento 2 issue or a Postfix issue.
Environment Magento 2.1.2 Postfix 2.11.0 Ubuntu 14.04.5 LTS Trusty Tahr
First to skip the obvious questions: Magento 2 configuration checks:
- Stores --> Configuration --> Sales --> Sales Emails --> All are enabled (Not that it matters as I am clicking on the send button of an existing order)
- Stores --> Configuration --> Advanced --> System --> Mail Sending Settings --> Disable Email Communications = No
To ensure that Magento is providing the correct details I added some logging statements into {magento_root}/vendor/magento/framework/Mail/Transport.php to spit out the contents of \Magento\Framework\Mail\MessageInterface $message and confirmed that the "To" value in the headers, the "to" and the "recipient" address were all correct.
Postfix settings: main.cf
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 = ipv4
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
mydestination = localhost.mydomain.co.uk, , localhost
myhostname = mydomain.co.uk
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
myorigin = /etc/mailname
readme_directory = no
recipient_delimiter = +
relayhost = [smtp.office365.com]:587
sender_canonical_maps = regexp:/etc/postfix/sender_canonical
# SMTP
smtp_always_send_ehlo = yes
smtp_generic_maps = hash:/etc/postfix/generic
smtp_send_dummy_mail_auth = no
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/smtp_sasl_password_map
smtp_sasl_security_options = noanonymous
smtp_sasl_tls_security_options = noanonymous
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
smtpd_sasl_auth_enable = yes
# TLS
smtp_tls_cert_file = /opt/bitnami/apache2/conf/www_mydomain_co_uk.pem
smtp_tls_key_file = /opt/bitnami/apache2/conf/www_mydomain_co_uk.key
smtp_tls_policy_maps = hash:/etc/postfix/tls_policy
smtp_tls_security_level = encrypt
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtp_use_tls = yes
smtpd_tls_cert_file = /opt/bitnami/apache2/conf/www_mydomain_co_uk.pem
smtpd_tls_key_file = /opt/bitnami/apache2/conf/www_mydomain_co_uk.key
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
generic
root@localdomain customerservices@mydomain.co.uk
@localdomain customerservices@mydomain.co.uk
sender_canonical
/.+/ customerservices@mydomain.co.uk
smpt_sasl_password_map
[smtp.office365.com]:587 customerservices@mydomain.co.uk:somepassword
tls_policy
smtp.office365.com encrypt
Now the output I'm seeing in /var/log/mail.log is:
May 10 16:23:01 mydomain postfix/pickup[11549]: 4D66124427: uid=1000 from=<bitnami>
May 10 16:23:01 mydomain postfix/cleanup[11580]: 4D66124427: message-id=<xxxxxxxxxxxxxx.xxxxxxxxxx@mydomain.co.uk>
May 10 16:23:01 mydomain postfix/qmgr[11550]: 4D66124427: from=<customerservices@mydomain.co.uk>, size=682, nrcpt=1 (queue active)
May 10 16:23:05 mydomain postfix/smtp[11582]: 4D66124427: to=<adminuser@mydomain.co.uk>, orig_to=<adminuser>, relay=smtp.office365.com[40.101.72.226]:587, delay=4.6, delays=0.02/0/4.2/0.37, dsn=2.6.0, status=sent (250 2.6.0 <20170510162301.$
May 10 16:23:05 mydomain postfix/qmgr[11550]: 4D66124427: removed
The to= is the admin username appended to the domain name and not the customers email in Magento.
The reason I am not sure if this is a Magento or Postfix issue is because sending a test email with:
echo "Test Message" | mail -s "Test Subject" someone@someemail.com
works fine!
Anyone have any ideas?