
lists-qmail at maexotic
Nov 26, 2009, 12:37 AM
Post #4 of 6
(2208 views)
Permalink
|
|
Re: limit outgoing email size but not incoming
[In reply to]
|
|
On Thu, Nov 26, 2009 at 10:29:17AM +0800, packets wrote: > As I know, both incoming and outgoing will reject emails more than > 3mb and I don't want to do that. This is not correct. DATABYTES only affects incoming messages per qmail-smtpd. Messages created locally or uploaded and sent eg. via a webmail system are *NOT* affected. Next you have to define what you mean by incoming and outgoing. Do you mean by "incoming" *every* message from *every* user that would be delivered to a local address/mailbox? And outgoing would be every message for a non-local user/mailbox? How about messages coming in for a local user that has a forward to an external address? Next is error handling. At what point do you want to reject the message? Somehow the message has to be uploaded to your server. Do you want to reject it at that point? If not, how will you handle the already injected message? Bounce it back to the sender? I guess to accomplish what you want I'd modify qmail-smtpd.c in smtp_rcpt(). Change ------------------------------------------------------------------------ if (!stralloc_0(&rcptto)) die_nomem(); out("250 ok\r\n"); } ------------------------------------------------------------------------ to ------------------------------------------------------------------------ if (!stralloc_0(&rcptto)) die_nomem(); if (addrallowed()) databytes = 0; out("250 ok\r\n"); } ------------------------------------------------------------------------ What does it do? For every connection that delivers a message to a local recipient (addrallowed() results in true) databytes is set to unlimited (aka turned off). If you now set DATABYTES to 3MB then every connection that requires a relay operation will be restricted to 3 MB, every connection with a local delivery will not. CAVEAT!!! SMTP allows more than one recipient with one message. the modification turns off DATABYTES if *ANY ONE* of multiple recipients of the message is local. So if there is a message of size 5 MB with 1 local and 1 remote recipient it will be accepted and delivered remote, even with the 5 MB size. Hope that helps, \Maex
|