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

I need to configure sendmail so that mail delivered for wildcard addresses is accepted for delivery and then delivered to a user, alias, or directly to a script.

I can rewrite the envelope/headers any number of ways, but I don't know how to accept the wildcard address when it's provided in RCPT TO: Everything I've tried so far winds up with a 550 user unknown error.

So here's a specific example:

I want to be able to handle any address that consists of a series of digits followed by a dot followed by a word, then pipe that to a script. If the headers get rewritten, that's OK, but I need the envelope to contain the actual Delivered-To address.

Here's the sort of SMTP session I need:

220 blah.foo.com ESMTP server ready; Thu, 22 Apr 2010 20:41:08 -0700 (PDT)
HELO blort.foo.com
250 blah.foo.com Hello blort.foo.com [10.1.2.3], pleased to meet you
MAIL FROM: <joe@foo.com>
250 2.1.0 <joe@foo.com>... Sender ok
RCPT TO: <12.arbitrary@foo.com>
250 2.1.5 <12.arbitrary@foo.com>... Recipient ok

I tried some stuff with regex maps, but I never got past 550 user unknown.

share|improve this question
add comment

2 Answers

up vote 0 down vote accepted

You should add a line in your /etc/mail/virtusertable like this:

@yourdomain.com account_catch_all

Then makemap the virtual user table, and all mail to that particular domain will be forwarded to the specified user. Then you can implement procmail to filter this according to whatever you need, or write your own scripts to parse the files...

share|improve this answer
add comment

I've done stuff like this by using the virtusertable. Not sure if this is exactly what you need but for example if you want to accept traffic for an entire domain and redirect it to a single address at another domain you'd put something like this in the virtusertable file:

@somedomain.com someuser@someotherdomain.com

Accept traffic for any address at somedomain and redirect it to the same address at someother domain:

@somedomain.com %1%3@someotherdomain.com

To do the rest of the pattern matching you mentioned you'd need to either use a regex map or (my preference) handle it with something like procmail after the fact.

virtual domains are described in section 4.8.51 of the O'Reilly 'sendmail' book ("the bat book").

I hope this is helpful.

share|improve this answer
add comment

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.