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: <[email protected]>
250 2.1.0 <[email protected]>... Sender ok
RCPT TO: <[email protected]>
250 2.1.5 <[email protected]>... Recipient ok
I tried some stuff with regex maps, but I never got past 550 user unknown.
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 [email protected]
Accept traffic for any address at somedomain and redirect it to the same address at someother domain:
@somedomain.com %1%[email protected]
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.
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...