Alias creation in Virtualmin

14 posts / 0 new
Last post
#1 Tue, 08/31/2010 - 19:58
jgbillings

Alias creation in Virtualmin

I have a user who hosts one domain in Virtualmin GPL. User would like to manage email aliases for the domain using virtualmin. Most aliases do not have mail accounts on the server, they are simply forwards to another email service (i.e. gmail).

The MTA on the server is postfix.

When an alias is added to the domain, by logging into Virtualmin and navigating to "Edit Mail Aliases" under that domain (again there is only one currently) the alias gets added to /etc/aliases, and the domain is prefixed on the address.

i.e. I'm trying to create alias1@domain.com to forward to address1@gmail.com and address2@gmail.com. When I use the Virtualmin interface to create it, I'll see and entry like this in /etc/aliases:

alias1-domain.com: address1@gmail.com,address2@gmail.com

The delivery to address "alias1@domain.com" fails since there is no account like that created in /etc/postfix/virtual, and postfix tries to deliver the message to alias1-domain.com@domain.com. We get an error from postfix that that virtual user doesn't exist.

Postfix has this configuration:


domain.com:~# postconf -n
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
broken_sasl_auth_clients = yes
config_directory = /etc/postfix
inet_interfaces = all
mailbox_size_limit = 0
mydestination = localhost
mynetworks = 127.0.0.0/8
myorigin = /etc/mailname
readme_directory = no
recipient_delimiter = +
relayhost =
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
smtpd_sasl_auth_enable = yes
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_domains = domain.com
virtual_alias_maps = hash:/etc/postfix/virtual

There are many aliases that were imported into the postfix/virtual file with the original setup. We want to add to and edit those aliases. When we manually just add the alias to the virtual file, it works fine. (after running postmap). Or using the webmin "Postfix Server" interface, but I'm curious if there is some misconfiguration in Virtualmin or Postfix, which isn't allowing the Virtualmin "Edit Alias" menu to work properly.

Thanks,
John

Wed, 09/01/2010 - 15:30
JamieCameron

That is odd, as in a case like this Virtualmin should add an entry to /etc/postfix/virtual like :

alias1@domain.com alias1-domain.com

Is that not happening on your system? The alias shouldn't even show up on the Edit Mail Aliases page unless this entry exists ..

''

Sat, 09/04/2010 - 16:05
jgbillings

When we login to Virtualmin, we have the Virtualmin theme enabled, so we see the status page and our domain is selected in the drop down box. When we click on "Edit Mail Aliases" in the nav menu, and the "Mail Aliases" page loads, it shows a list of all our aliases set in /etc/postfix/virtual. There were many imported when the site was installed, and we also can use the Webmin postfix module to edit these aliases.

When we click on the "Add an alias to this domain." link on the "Mail Aliases" page in Virtualmin, we see a form. There are two tabs for this form, "Basic Mode" and "Advanced Mode".

Basic Mode has these fields:


Name All mailboxes Mailbox @domain.com
Deliver locally? Yes, deliver to mailbox
Bounce mail? Yes, send bounce reply
Forward to other address? Yes, forward to addresses
Forward to everyone in domain? Send to all mailboxes
Send automatic reply? Yes, respond with message ..

On the Name field, I check the radio button for "Mailbox" and enter "testalias2" and the domain part is added there already.

I check the box "Forward to other address?" and I enter a remote email address.

Then I click the "Create" button at the bottom of the form.

The "Mail Aliases" page loads again showing all our aliases, and I see the new alias I just added:

[checkbox] testalias2 Address john@rimuhost....

The alias is added correctly:

tail -1 /etc/postfix/virtual
testalias2@domain.com john@rimuhost...

I go to the same form again by clicking "Add an alias to this domain." This time I added two remote addresses for messages to be forwarded.

[checkbox] testalias3 Address john@rimuhost....

Basically the entry is identical to the one I previously added, accept for the number.

I check the postfix virtual file:

tail -1 /etc/postfix/virtual
testalias3@domain.com testalias3-domain.com

And I see this in /etc/aliases:

# tail -1 /etc/aliases
testalias3-domain.com: john@rimuhost...,,john@other.com

The second address is not displayed on the "Mail Aliases" page, but I see the address I entered above.

When I try to deliver to that alias I get this:

postfix/error[27814]: 37635605E3: to=, relay=none, delay=0.03, delays=0.01/0.01/0/0.01, dsn=5.0.0, status=bounced (User unknown in virtual alias table)

And the same error essentially, when deliver to the intended alias:

postfix/error[27853]: 3A2B060658: to=, orig_to=, relay=none, delay=0.02, delays=0/0.01/0/0.01, dsn=5.0.0, status=bounced (User unknown in virtual alias table)

I believe the same behavior happens when using the advanced form. Works for one alias, but not more than one. I'm not sure what the problem is, is there some misconfiguration with how this virtual domain is setup or are we not doing this right? Thanks for your feedback.

Sat, 09/04/2010 - 21:00 (Reply to #3)
JamieCameron

Is this actually the final line in your /etc/postfix/virtual file?

testalias3-domain.com: john@rimuhost...,,john@other.com

It looks like Virtualmin is adding the line wrongly, and I'd like to see exactly what it is putting in that file..

''

Sun, 09/05/2010 - 13:58 (Reply to #4)
jgbillings

That line is going into /etc/aliases, not /etc/postfix/virtual. I've only changed the domains and obfuscated the one email address. There are two commas between the addresses for some reason.

Here with only the user's domain changed:

:~# tail -1 /etc/aliases testalias3-domain.com: john@rimuhosting.com,,john@nimhq.net

Sun, 09/05/2010 - 14:36 (Reply to #5)
JamieCameron

Those two commas sound like the cause of the problem..

If you manually edit /etc/aliases and replace the two commas with one, and then run newaliases , does delivery work OK?

''

Mon, 09/06/2010 - 18:08 (Reply to #6)
jgbillings

I manually removed the extra comma:


# tail -1 /etc/aliases
testalias3-domain.com: john@rimuhosting.com,john@nimhq.net

I ran the newaliases command. I get the same error when attempting delivery:


Sep 6 23:03:46 domain.com postfix/qmgr[31336]: A36A3605B0: from=, size=293, nrcpt=1 (queue active)
Sep 6 23:03:46 domain postfix/error[31348]: A36A3605B0: to=, orig_to=, relay=none, delay=0.03, delays=0.01/0.01/0/0.01, dsn=5.0.0, status=bounced (User unknown in virtual alias table)

I confirmed the entry in /etc/postfix/virtual:


# tail -1 /etc/postfix/virtual
testalias3@domain.com testalias3-domain.com

Mon, 09/06/2010 - 19:48 (Reply to #7)
JamieCameron

Another thing to check is that in /etc/postfix/main.cf the mydestination line does not contain whatever domain.com is. If it contains $myhostname or $mydomain , make sure your system's hostname does not contain or equal domain.com

''

Tue, 09/07/2010 - 14:21 (Reply to #8)
jgbillings

The output from "postconf -n" is included above. That line has this:

mydestination = localhost
Tue, 09/07/2010 - 14:51 (Reply to #9)
JamieCameron

You might want to change that to your system's full hostname instead, then restart Postfix.

''

Wed, 09/08/2010 - 18:41 (Reply to #10)
jgbillings

Due to privacy concerns I can't use the real hostname, so substituting domain.com...

when I run hostname:


domain.com:~# hostname
domain.com

If I enter the hostname here:


domain.com:~# postconf -n | grep mydestination
mydestination = localhost

According to the postfix documentation here:

http://www.postfix.org/VIRTUAL_README.html#virtual_alias

If I enter that domain there, I'll need to remove it from where it's currently configured here:

domain.com:~# postconf -n | grep virtual_alias_domains
virtual_alias_domains = domain.com

The documentation says:

NEVER list a virtual alias domain name as a mydestination domain!

If I configured the domain.com in "mydestinations" then I would have to move all the aliases to /etc/aliases? Is this what you suggest I should do?

Wed, 09/08/2010 - 23:50 (Reply to #11)
JamieCameron

I'd suggest first removing it from virtual_alias_domains - that might be the source of the problem.

''

Sat, 09/11/2010 - 19:10 (Reply to #12)
jgbillings

I'm not able to troubleshoot this any further. The solution for us in this case is to not use the "Edit Mail Aliases" menu in Virtualmin. Instead we use the "Virtual Domains" menu in the Postfix Webmin module to edit/add aliases.

Sun, 09/05/2010 - 14:00 (Reply to #13)
jgbillings

The last line in /etc/postfix/virtual:


:~# tail -1 /etc/postfix/virtual
testalias3@domain.com testalias3-domain.com

Topic locked