LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 12-20-2008, 07:40 AM   #1
aaronvegh
LQ Newbie
 
Registered: Jun 2004
Posts: 15

Rep: Reputation: 0
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.
 
Old 12-20-2008, 12:34 PM   #2
Berhanie
Senior Member
 
Registered: Dec 2003
Location: phnom penh
Distribution: Fedora
Posts: 1,625

Rep: Reputation: 165Reputation: 165
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

Last edited by Berhanie; 12-20-2008 at 12:49 PM.
 
Old 12-20-2008, 12:41 PM   #3
aaronvegh
LQ Newbie
 
Registered: Jun 2004
Posts: 15

Original Poster
Rep: Reputation: 0
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.
 
Old 12-20-2008, 01:03 PM   #4
Berhanie
Senior Member
 
Registered: Dec 2003
Location: phnom penh
Distribution: Fedora
Posts: 1,625

Rep: Reputation: 165Reputation: 165
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.

Last edited by Berhanie; 12-20-2008 at 01:04 PM.
 
Old 12-20-2008, 08:42 PM   #5
aaronvegh
LQ Newbie
 
Registered: Jun 2004
Posts: 15

Original Poster
Rep: Reputation: 0
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.
 
Old 12-21-2008, 08:44 AM   #6
Berhanie
Senior Member
 
Registered: Dec 2003
Location: phnom penh
Distribution: Fedora
Posts: 1,625

Rep: Reputation: 165Reputation: 165
You're welcome, Aaron.
 
Old 07-14-2011, 05:52 PM   #7
johnjreeve
LQ Newbie
 
Registered: Jun 2008
Posts: 4

Rep: Reputation: 0
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/
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
vhost configuration for CNAME wildcard subdomains leif_84 Linux - Server 1 01-08-2008 02:13 AM
Virtual subdomains? timothyb89 Linux - Server 4 10-04-2007 06:44 AM
wildcard emails using postfix rezaan.marlie Linux - Newbie 3 05-17-2007 08:37 AM
virtual hosts subdomains zenerdiode Linux - Server 5 04-30-2007 12:29 PM
make wildcard subdomains on localhost work edman007 Linux - Networking 5 09-03-2005 01:41 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 03:44 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration