Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Limiting the size of incoming mail – by user? 1

Status
Not open for further replies.

butler

MIS
Oct 12, 1998
88
US
Hi all,

I am running send mail on an IBM RS/6000. I am wondering if there is a way to limit the incoming mail size for only a specific range of users? Or can I block attachments for a group of users? (I need to do this because some users are connect to the RS/6000 over a 56K frame relay line, and incoming ‘spam’ mail can really degrade network performance at these locations.)

Thanks,
bill
 
you could route the email of certain users to a perl (or other) script, and let the perl script determine the size of STDIN. if the email is too big, you could then bounce it by printing an error message, then returning an error code. the error codes are standard. exiting with 0 is success, 75 tells sendmail to try again later (queue it), 67 is invalid host, 68 is invalid user...
you could just exit with some other made up error code.

on success, you'd have to have sendmail deliver it locally, i guess. but, this might help?
 
Thanks, This sounds good, but I'm not sure how to get started. Do you have a sample perl code? How do I route a users mail to a script?
 
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.


 
Wow, thanks for your detailed answer. I am going to give this a try. I am currently running sendmail on an ibm aix and am having a lot of strange problems. I need to set up a test system to play with so that I can work thru things.

Thanks much,
bill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top