Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I'm having problems trying to configure a catch all email in postfix.

I have an email account messages@example.com. All emails sent to this address are piped to a php script.

What I would like to do is forward all emails in the format anything.messages@example.com, e.g. 3454534.messages@example.com and dsf843fdd.messages@example.com, to this email account.

After doing some research I've done the following but to no avail.

In /etc/postfix/main.cf I have added the line

virtual_alias_maps = hash:/etc/postfix/virtual

In /etc/postfix/virtual I have added

/.*messages@example.com   messages

Any help is appreciated! Thanks.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Nowhere is it documented that hash maps support this kind of wildcarding - you're probably thinking about regexp or PCRE tables:

http://www.postfix.org/PCRE_README.html
http://www.postfix.org/pcre_table.5.html

Something like this should work:

/etc/postfix/wildcard.pcre: /^\d+\.message@example\.com$/ message

Note that PCRE maps are not compiled; don't run postmap on them.

However, I would strongly suggest you switch to using recipient delimiters instead; it makes all of this unnecessary.

share|improve this answer
    
Actually, \d+ will only match digits and the user wants to match everything so \w+ should be used. Also, a quick way to check it's working is by using postmap (yes it works) like that: postmap -q 'foo.messages@example.com' pcre:/etc/postfix/wildcard.pcre –  fim Mar 1 '12 at 11:11
    
@adaptr Thanks for your response. I've created wildcare.pcre as suggests and run the command above, but it returns nothing. Do I take that as a sign it is working? Do I need to reference the pcre table in main.cf? –  leejmurphy Mar 1 '12 at 15:03
    
...yes, obviously. Just add it at the end of your virtual_alias_maps config: virtual_alias_maps = hash:/etc/postfix/virtual, pcre:/etc/postfix/wildcard.pcre –  adaptr Mar 1 '12 at 15:07
    
Nothing seems to be happening. messages@example.com are still being routed, but foo.messages@example.com aren't, nor are they being returned to sender. I've tried checking the maillog but for some reason it hasn't updated since this morning, probably another issue entirely –  leejmurphy Mar 1 '12 at 15:28
    
my bad, i missed the backslash escape on the .com. Seems to be working great, thanks! –  leejmurphy Mar 1 '12 at 15:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.