well, there's a lot involved.
first you need to create a mail alias by editing /etc/alias:
some-mail-user: "| /Clifford"
this says that for any email that goes to some-mail-user, you send the entire contents as STDIN to the script /Clifford
where /Clifford is the script name (i decided to put the script in the root directory, because when mail bounces, it shows the handler (i'm sure there's a way to disable that)..so, /Clifford is just a symbolic link to where the real script is..cause i'm paranoid about letting anyone know anything about my filesystem
edit the virtusertable:
/etc/mail/virtusertable
to route a whole domain's email to a user:
@yourdomain.com some-mail-user
now, any email that goes to the domain, yourdomain.com, is routed to alias some-mail-user, which in turn is sent to /Clifford, the script you set up.
but, this gets much trickier, as you'll see. there might be an easier method for you to use, this is what i've been doing. i had to overcome the following problems:
1. Sendmail doesnt like to send copies of an email to a person, so if you're sending FROM your server to multiple recipients at this domain, it says, "wait a minute, i dont want some-mail-user to get more than one copy of this email!" - so it sends only one copy to some-mail-user for all the people the email might be CC'd or BCC'd to that are in some-mail-user's handled domains. All emails sent FROM my server without an MUA to these addresses are sent individually, to avoid this.
2. It's hard for the script to tell who the email is actually supposed to be to, by reading the script. You can go into /etc/sendmail.cf, and add or modify the headers that Sendmail will prepend at to the email. The receiving email user/address is stored in the Sendmail macro:
$u
so, i printed out my own header, to make it easier on me:
X-Intended-User: $u
now, this isn't the format of the sendmail.cf, but you'll see how that works when looking at it.
like i said, this became a huge runaround, and was necessary for this very complex stuff i'm trying to do. Qmail makes life easier, but i wanted to use Sendmail for its wealth of features i might use later down the road. this might all be done easier for what you need, maybe not?
so, once your perl script determines who owns this email, you could look it up in your database to see if this person is allowed to receive emails this big, and if so, put it in their mailbox by redirecting it to the mail users' name, and if not, then just bounce it with:
exit 75;
or, to save the outgoing bandwidth, send an email back saying, "Sorry, this email was too big. the attachment was not sent back"...or something.
but in any case, if you go this route, this will save you the days and headaches i've dealt with. You're probably goin to have someone here say this way is just too complicated...so lemme know what you end up doin
good luck,
blake.