LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Postfix Virtual Wildcard Subdomains (https://www.linuxquestions.org/questions/linux-server-73/postfix-virtual-wildcard-subdomains-691877/)

aaronvegh 12-20-2008 07:40 AM

Postfix Virtual Wildcard Subdomains
 
Hi there,
I have setup Postfix to use virtual domains with non-UNIX account users. What would you call this: virtual domains delivering to virtual accounts? Anyway, it's fine. I'd like to accept mail for all subdomains of the main domain, but I can't get it to work.

For example, I currently accept mail to @amazingmac.ca. I'd like to accept mail for any subdomain of the same, with the mail delivered to a catchall address. If it makes things any easier, all mail to the domain goes to just the one address.

The message I get when I try sending to user@subdomain.amazingmac.ca is "relay access denied". The server receives the mail, but rejects it.

I've seen elsewhere some suggestion that the directive virtual_alias_maps should point to a regexp file, which I have tried in the current configuration, but it doesn't work.

Here's the files and all their relevant contents:

Code:

root@ubuntu:/etc/postfix# postconf -n
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
config_directory = /etc/postfix
inet_interfaces = all
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
mydestination = localhost.localdomain, localhost
myhostname = localhost
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
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 (Ubuntu)
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, regexp:/etc/postfix/subdomain-catchall
virtual_gid_maps = static:1001
virtual_mailbox_base = /var/spool/vmail
virtual_mailbox_domains = /etc/postfix/vhosts.txt
virtual_mailbox_maps = hash:/etc/postfix/vmaps.txt
virtual_uid_maps = static:1001

Code:

root@ubuntu:/etc/postfix# cat virtual
@amazingmac.ca catcher@amazingmac.ca

Code:

root@ubuntu:/etc/postfix# cat subdomain-catchall
/@[^@]*\.amazingmac\.ca$/ catcher@amazingmac.ca

Code:

root@ubuntu:/etc/postfix# cat vhosts.txt
amazingmac.ca

Code:

root@ubuntu:/etc/postfix# cat vmaps.txt
catcher@amazingmac.ca amazingmac.ca/catcher/

Thanks in advance for any help!
Aaron.

Berhanie 12-20-2008 12:34 PM

Your vhosts.txt should be
Code:

amazingmac.ca
.amazingmac.ca

Also, the catchall address belongs in vmaps.txt, not virtual, unless the catchall address is the only address you have for the virtual mailbox domains.

Addendum:

Regarding the regexp question, you can have something like this:
Code:

virtual_mailbox_maps  = regexp:/path/to/vmaps.txt
And, in vmaps.txt
Code:

/^bob@amazingmac\.ca$/          somewhere/bob
/^alice@sub.amazingmac\.ca$/    somewhere/alice

/[@.]amazingmac\.ca$/          somewhere/bob


aaronvegh 12-20-2008 12:41 PM

Thanks so much for responding!

I added the ".amazingmac.ca" to vhosts.txt, and still the same response: "relay access denied".

Quote:

Also, the catchall address belongs in vmaps.txt, not virtual, unless the catchall address is the only address you have for the virtual mailbox domains.
The catchall address IS the only address.

Berhanie 12-20-2008 01:03 PM

Quote:

The catchall address IS the only address.
Ok, so you can just make virtual regexp table, unless you want a different catchall for each subdomain.
Also, please take a look at my first post again, since I made some additions to it.

Debugging suggestions:

1. make sure you can send mail to the parent domain first.
2. make sure a catchall works for the parent using a hash table for virtual.
3. keeping a hash format for virtual, add a catchall for a specific subdomain and test it.
4. now use regexp for virtual.

aaronvegh 12-20-2008 08:42 PM

Hi Berhanie,
Thanks again for going above and beyond for me here. Everything is working now! In particular, your advice about how to use the regexp was spot-on; this is clearly an area where I'm weak.

You're the man!

Cheers,
Aaron.

Berhanie 12-21-2008 08:44 AM

You're welcome, Aaron.

johnjreeve 07-14-2011 05:52 PM

I found this thread particularly useful for setting up virtual wildcard subdomains on my server. So I wrote up everything I did and put it into a blog post. Hope this helps:
http://www.myintervals.com/blog/2011...fix-and-linux/


All times are GMT -5. The time now is 07:24 AM.