Postfix Virtualmin Username and Domain

Hi,

Would appreciate if someone might be able to assist me. I have virtualmin setup for just website hosting for our clients. We have DNS and mail hosted elsewhere. I do not have the mail feature enabled for virtual servers as I only want to relay them. Usernames are just a standard format of “user”.

OS: Ubuntu 18.04
Virtualmin: 6.09
Webmin: 1.942
Postfix: 3.3.0

I have postfix setup on this Virtualmin webserver to relay email to another postfix server via sasl authentication and this works fine.

However, I need to fine tune the from address in the emails being sent via the virtualmin websites.

Emails are being sent as the hostname.FQDN. mail.log is showing it as
from=username@servername.serverdomain.com
What I would like it to do it send as
from=username@customersdomain.com.

I thought the (Rewrite “user” to “user@$mydomain”) would be converting it but doesn’t appear to be.

alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
broken_sasl_auth_clients = yes
compatibility_level = 2
empty_address_recipient = - MAILER-DAEMON
home_mailbox = Maildir/
inet_interfaces = all
inet_protocols = all
mailbox_command = /usr/bin/procmail-wrapper -o -a $DOMAIN -d $LOGNAME
mailbox_size_limit = 0
mydestination = $myhostname, webserver01, localhost.localdomain, localhost, webserver01.contoso.com
myhostname = webserver01.contoso.com
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
readme_directory = no
recipient_delimiter = +
relayhost = relayserver.contoso.com:587
sender_bcc_maps = hash:/etc/postfix/bcc
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/relay-passwd
smtp_sasl_security_options =
smtp_tls_security_level = may
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtp_use_tls = yes
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
smtpd_recipient_restrictions = permit_mynetworks permit_sasl_authenticated reject_unauth_destination
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
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
virtual_alias_maps = hash:/etc/postfix/virtual

Hi @ITOC-DW

Welcome.

When you say

I’m taking that to read from contact forms or similar.

I’ve had something similar in the last day - a contact form on a web page (the Virtual Server only has HTTP & HTTPS enabled, no mail) would send mail via PHP mail() and the recieved mail would have the reply-path set as username@servername.serverdomain.com.

I was setting the rest of the headers correctly - the FROM, TO, etc. A bit of Googling showed that I needed to set the 5th parameter in the mail() command with a “-f” to set the return path.

If you aren’t using mail() command to send the emails from your website - check how you are setting the headers with whatever you are using.

Masquerading can be done in Postfix - but I know how to do it by altering the main.cf file & from the CLI, I don’t know (yet) how to do it from the Virtualmin GUI. In my case I chose to correct what the PHP mail() was doing rather than get Postfix to override it.

HIH

Dibs

Hi,

Really appreciate the response. The problem is we don’t have access to the actual website content as it’s multiple customers that use different web developers. They are just leveraging our configuration via postfix to relay the emails and I think the email formatting would fall in our management. I’m sure that response will help others though.

I did see someone on this forum use Canonical Mapping but they were not able to automate it. I feel like its something to do with the Webmin > Servers >Postfix Mail Server > Address Rewriting and Masquerding. Could be that or I need to set an email address for each user somewhere?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.