Postfix configuration - how to change user.user@hostname.fqdn.com to user@domain.com

I note that in my default configuration, I have a number of Virtual Servers that all host different domains.
in one virtual server, i have 2 users (aaasq) which is the ftp user created when i setup the virtual server?

Now i need to create another email account…this example uses a president, so i have created an email address president@domain.com. However,
Virtualmin appears to do the following:

president.aasq@hostname.fqdn.com

Now I wish to utilize this new email account to link with Domain registry contact, so the email address must be:

president@domain.com

How do i fix my above problem?

Have you looked in Webmin - Servers - Postfix Mail Server - Address Rewriting & Masquerading ?

Will that work for both inbound and outbound email for president@domain.com?

For example the registry is going to send emails to president@domain.com (not president.aaasq@hostname.fqdn.com)

It’s both inbound & outbound - mine are set up as

Rewrite “user%domain” to “user@domain” = Yes
Rewrite “user” to “user@domain” = Yes
Rewrite “user@host” to “user@host.$mydomain” = No
Rewrite “user!site” to “user@domain” = Yes

Then the 3 boxes below to

  • MAILER-DAEMON
    None
    None

My users are set up as user. My outbound go as user@mydomain.com and inbound emails coming to user@mydomain,com turn up in the users mailboxes.

HIH

Dibs

Yes my Webmin>Servers>Address Rewriting and Masquerading settings the same as yours above.

And emails still go out as user.user@hostname.fqdn.com ?

Have you tried in Webmin - Servers - Postfix: Reload Configuration, then Stop PostFix & Start Postfix? Issue still persists?

And you’ve sent an email to say a gmail or hotmail account and examined the headers?

On the domain in question - create a new user. Virtualmin (making sure the domain is correct in the dropdown) - Edit Users - Add a User to this server.

Then set president1 as the email address - your domain name should already show on the screen. In Other User permission - just verify it says Email Only.

Then send an email to that user from Hotmail/Gmail - does it arrive? Send Hotmail/Gmail an email from that account & check the headers to see who the envelope-from states. If you haven’t got as far as setting SPF records for the domain - there is a chance that the email to Hotmail\Gmail might end up in Spam\Junk or be rejected. But Hotmail\Gmail should still be able to send an email and you can check correct receipt of that.

I personally don’t have an email or anything else associated with a Virtual Server’s primary account. That isn’t what you are try to do is it?

I am sure that the problem is FTP login when new user is created. Now that I have followed the following forum thread…https://www.virtualmin.com/node/20128

I note that Erik says, when configuration is changed so that its user@domain.com, you have to start over (ie delete user and create a new one). So after making the configuration changes, I created a new user secretary. virtualmin now correctly shows this as secretary@domain.com

Others stated on the thread link I have added above, that they could simply edit the user in webmin>System>Users and Groups. So I will try this for president.aaasq and report back what happens.

Cool - glad you are making progress. Report back on how you get on.

Thanks

ok so I can easily send emails from my Virtualmin virtual servers, and they are being received at the other end as (eg) president@domain.com or secretary@domain.com.

having said that, for some reason, I am unable to receive emails unless they are sent too user@hostname.fqdn.com (the webserver itself…not the virtualmin>virtual server/domain).

Your message couldn’t be delivered. Despite repeated attempts to deliver your message, querying the Domain Name System (DNS) for the recipient’s domain location information failed.

I am not using the Bind to control dns on the hosting server. I simplly point an A record at the server ipaddress…so dns is controlled externally by registrar.

I note that in Virtualmin docs it says…if one wishes to have multiple domains using emails where there is a chance "joe"@domain.com could be used for any number of different domains, any email sent to “joe” would get delivered to any user on the entire webhosting server. That makes one figure, ok, I need to setup Postfix Virtual Hosting…however, then i read the following…

Postfix Virtual Hosting
Note: Webmin can be used for virtual hosting most easily with the Virtualmin hosting control panel. It automates all of the following tasks, as well as many others commonly needed in a virtual hosting environment, such as setting up email, name service, and databases

this is all good and well, however, where in the docs does it provide an example of a stock Virtualmin installation, where Postfix and Dovecot are working, for us to compare with? (this is a huge problem)

what i really need is a detailed working example of exactly how to configure a postfix/dovecot mail server in Webmin/Virtualmin that can provide email for multiple domains+SSL with the format mail@domain.com (not “mail@hostserver.fqdn.com”).

Even when we go onto the web looking for other tutorials on setting up postfix, one thing i really struggle with is the inconsistency in naming convention used in Virtualmin…it does not exactly line up with commonly used terms in various tutorials on the internet. So its easy for those on this forum who are way less skilled than me (and whilst i am good with webhosting, email servers certainly aren’t my forte)

I have sent an email to president@domain.com, then checked webmin>postfix mail server>Mail queue…its empty.

Does multiple domains work with mail if I am not using Bind in Virtualmin? (ie Virtualmin>Edit Virtual server> dns domain enabled = unchecked

How does president@domain.com resolve in Virtualmin if “dns domain enabled” is not checked? (i ask this because of dns error above)

Do you have an MX record for the domain?

Yes i do have mxrecords.

Emails are being sent out from this user in webmin, but not received by this user (no inbound) …its almost like dovecot isnt working properly because in Usermin the create mail button isnt working and i occasionally get a pop3 authentication error (i am using IMAP)

Where are the docs for “detailed” postfix/dovecot configuration for virtualmin?

Can i just use docs from elsewhere that are more informative? (Such as the ISPConfig ones at howtoforge.com)

Open up 2 Chrome tabs (or whatever browser you use). In one - go to “Webmin - System - System Logs” and click on View for file /var/log/mail.log. It should be Yes for Active. If not that’s another issue - but in a default install, it should be Yes.

In the 2nd browser tab - open your Hotmail\Gmai or external mail -send an email to president\secretary email account an email.

Once sent - go to Tab 1 (the mail log) and hit refresh a few times if need to be to see what happens. PostFix should log the incoming email and what it does with it.

I just sent my email address on a domain (virtual server) an email from my Yahoo account and saw the following lines in my log

Oct 15 20:05:06 host1 postfix/smtpd[27776]: connect from sonic303-21.consmr.mail.ir2.yahoo.com[77.238.178.202] Oct 15 20:05:07 host1 policyd-spf[27779]: None; identity=helo; client-ip=77.238.178.202; helo=sonic303-21.consmr.mail.ir2.yahoo.com; envelope-from=myemail@yahoo.co.uk; receiver=email.address@mydomain.com Oct 15 20:05:07 host1 policyd-spf[27779]: Pass; identity=mailfrom; client-ip=77.238.178.202; helo=sonic303-21.consmr.mail.ir2.yahoo.com; envelope-from=myemail@yahoo.co.uk; receiver=email.address@mydomain.com Oct 15 20:05:07 host1 postfix/smtpd[27776]: 7DF9D3CCF9: client=sonic303-21.consmr.mail.ir2.yahoo.com[77.238.178.202] Oct 15 20:05:07 host1 postfix/cleanup[27780]: 7DF9D3CCF9: message-id=<1466283496.3307480.1571166302794@mail.yahoo.com> Oct 15 20:05:07 host1 postfix/qmgr[1635]: 7DF9D3CCF9: from=, size=3557, nrcpt=1 (queue active) Oct 15 20:05:07 host1 postfix/smtpd[27776]: disconnect from sonic303-21.consmr.mail.ir2.yahoo.com[77.238.178.202] ehlo=2 starttls=1 mail=1 rcpt=1 data=1 quit=1 commands=7 Oct 15 20:05:08 host1 spamd[27920]: spamd: connection from ::1 [::1]:44456 to port 783, fd 5 Oct 15 20:05:08 host1 spamd[27920]: spamd: setuid to email.address@mydomain.com succeeded Oct 15 20:05:08 host1 spamd[27920]: spamd: processing message <1466283496.3307480.1571166302794@mail.yahoo.com> for email.address@mydomain.com:1012 Oct 15 20:05:08 host1 spamd[27920]: spamd: clean message (1.2/6.0) for email.address@mydomain.com:1012 in 0.3 seconds, 3699 bytes. Oct 15 20:05:08 host1 spamd[27920]: spamd: result: . 1 - BAYES_50,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,HTML_MESSAGE,MIME_HTML_MOSTLY,RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS scantime=0.3,size=3699,user=email.address@mydomain.com,uid=1012,required_score=6.0,rhost=::1,raddr=::1,rport=44456,mid=<1466283496.3307480.1571166302794@mail.yahoo.com>,bayes=0.463198,autolearn=no autolearn_force=no Oct 15 20:05:08 host1 postfix/local[27781]: 7DF9D3CCF9: to=, orig_to=, relay=local, delay=2.1, delays=1.3/0.01/0/0.83, dsn=2.0.0, status=sent (delivered to command: /usr/bin/procmail-wrapper -o -a $DOMAIN -d $LOGNAME) Oct 15 20:05:08 host1 postfix/qmgr[1635]: 7DF9D3CCF9: removed

and the email is in the inbox when I checked the local account.

Obviously hostname, sender & recipient have been generic’d to host1, myemail@yahoo.co.uk & email.address@mydomain.com.

Can you post up your DNS records for the domain in question? There’s nothing top secret in them. :wink:

Ok so i have found at least one error in my dns that i should have picked up on before and at least now i am getting somewhere.

At some point in the past (not sure when it was now), I have either inadvertantly deleted (or simply forgot to add in) the following “A record”…

mail.domain.com @ serverip address

So at least now, i immediately get the following postmaster error when i attempt to send email to president@domain.com

server1.host.com.au rejected your message to the following email addresses:
president@domain.com.au (president@domain.com.au)
The address you sent your message to wasn’t found at the destination domain. It might be misspelled or it might not exist. Try to fix the problem by doing one or more of the following:

  1. Send the message again, but before you do, delete and retype the address. If your email program automatically suggests an address to use, don’t select it.
  2. Clear the recipient AutoComplete cache in your email program by following the steps in this article: Status code 5.1.1. Then resend the message, but before you do, be sure to delete and retype the address.
  3. Contact the recipient by some other means (by phone, for example) to confirm you’re using the right address. Ask them if they’ve set up an email forwarding rule that could be forwarding your message to an incorrect address.

server1.host.com.au gave this error:
president@domain.com.au: Recipient address rejected: User unknown in virtual alias table

So, i believe that if i sort out the Virtual Alias table, things should work. My question now is, i thought that Virtualmin was supposed to do this automatically?

P.S. Also getting the same postmaster error for secretary@domain.com

Mail doesn’t normally have an A record. Usually, in the cases I’ve seen\experienced, the IP address has an A record with @ and there are CNAME’s for the aliases like www, ftp, mail. Then there is an MX record pointing to the mail.domain.com (effectively the CNAME).

Post up what you have for the DNS records please? Generic out the names & set the IP to 1.1.1.1 if you’d prefer?

I’ve got a out of the box install of Virtualmin and adding new VirtualServers (did one in the last 2 weeks) - I’ve not had issues with anything (bar the recent 6.04 + Apache thing about *:80 vs IP:80 but that’s not relevant here).

Nor had issues with the Alias table or anything else of significance. Even “adjusting” Postfix to become more secure can be done from the GUI.

Also DNS changes take time to propogate.

Actual Registrar DNS are as follows…
domain.com.au. SOA 3600 ns1.partnerconsole.net.
domain.com.au. A 300 1.1.1.1
mail A 3600 1.1.1.1
webmail A 300 1.1.1.1
www CNAME 3600 domain.com.au.
domain.com.au. MX 3600 mail.domain.com.au. 5
domain.com.au. NS 3600 ns1.partnerconsole.net.
domain.com.au. NS 3600 ns2.partnerconsole.net.
domain.com.au. NS 3600 ns3.partnerconsole.net.
domain.com.au. TXT 300 “v=spf1 a mx a:domain.com.au ip4:1.1.1.1 ip4:1.1.1.1 ip6:fe80::5400:1ff:fef1:5674 ?all”





suggested records by virtualmin use an A record for mail.domain.com (see below)

domain.com. IN A 1.1.1.1
www.domain.com. IN A 1.1.1.1
ftp.domain.com. IN A 1.1.1.1
m.domain.com. IN A 1.1.1.1
localhost.domain.com. IN A 127.0.0.1
webmail.domain.com. IN A 1.1.1.1
admin.domain.com. IN A 1.1.1.1
mail.domain.com. IN A 1.1.1.1
domain.com. IN MX 5 mail.domain.com.
domain.com. IN TXT “v=spf1 a mx a:domain.com ip4:1.1.1.1 ip4:1.1.1.1 ip6:fe80::5400:1ff:fef1:5674 ?all”




EDIT…
I am confused that the mail record error popped up, because i have just realised that i had the following mxrecord anyway…

domain.com.au. MX 3600 mail.domain.com.au. 5
should this record have resolved without me having to also add an A record?

can you also look over my etc/postfix/main.cf

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

#Define the domain list as hash file or as list in the config file.
#virtual_alias_domains = hash:/etc/postfix/virtual_domains

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 (Debian/GNU)
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/postfix/postfix.cert.pem
smtpd_tls_key_file = /etc/postfix/postfix.key.pem
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
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
myorigin = $mydomain
mailbox_size_limit = 0
recipient_delimiter = +
inet_protocols = all
virtual_alias_maps = hash:/etc/postfix/virtual
sender_bcc_maps = hash:/etc/postfix/bcc
mailbox_command = /usr/bin/procmail-wrapper -o -a $DOMAIN -d $LOGNAME
home_mailbox = Maildir/
smtpd_sasl_auth_enable = yes
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions = permit_mynetworks permit_sasl_authenticated reject_unauth_destination
smtp_tls_security_level = dane
mynetworks_style = subnet
smtpd_tls_CAfile = /etc/postfix/postfix.ca.pem
smtpd_error_sleep_time = 5s
myhostname = host.domain.com.au
mydestination = $myhostname, $mydomain, localhost.$mydomain, domain.com.au, localhost.domain.com.au, localhost
default_process_limit = 2
mydomain = domain.com.au