OT: Blocking oversized messages during SMTP transaction

Richard.Hall Richard.Hall at INGENTA.COM
Wed Jun 15 14:32:13 IST 2005


Jim,

On Tue, 14 Jun 2005, Jim Holland wrote:
[...]
> We have only very limited bandwidth - 64k for 2,500 (yes) e-mail users -

Ouch :-(

> so need to utilise our bandwidth as efficiently as possible.  We have
> therefore configured the maximum message size in sendmail 8.13.1 to 1.5 MB.
> This normally works fine with intelligent mail systems that understand
> what "250-SIZE 1500000" means.
>
> However some systems such as Yahoo and, surprisingly, GoogleMail, fail to
> use the SIZE extension when sending us mail.  The result is that we accept
> large messages from them as we don't know what the message size is going
> to be in advance, and then when the specified size limit is reached for
> the temporary mail file, sendmail still stupidly insists on continuing
> with the transaction even though it will no longer write to disk.
[...]
> Is there any automated solution to this?  We need to be able to terminate
> the session with an appropriate error message the moment it is apparent
> that the message is too large.  Can sendmail be made to issue a fatal
> error message during the DATA phase of the SMTP transaction?  Or is the
> crunch time when we need to bite the bullet and change to say Exim instead?
[...]

Much as I love Exim, and despite the fact that sendmail's config makes me
feel nauseous, I don't believe that Exim can help you here. But nor can
sendmail IMHO. The problem is the SMTP protocol itself, which only gives
you two (relevant) points at which you can reject the message:-

1) immediately after receiving the DATA command - but that is obviously
   too soon for you, as you don't yet know the size;

2) after the terminating '.', when you do know the size - but by then it
   is too late, as you clearly appreciate.

In between those two points the traffic is all "one-way".  The SMTP
protocol does not define any way to stop the data transmission in
mid-stream, except by dropping the connection. And the other end will
treat that as a temporary failure, and retry later. Ah, you know that ...

> This evening some idiot tried to send us 12 separate copies of a 4,5 MB
> message!  Killing the connections doesn't work as Yahoo obviously just
> keeps resending.  I had to wait until it became apparent who the sender
> was, then blacklist them in the access file and only then kill the
> connections.

The best I can suggest at the moment is that you limit the number of
simultaneous connections from one IP address, eg so that you only have one
rogue connection at a time. Exim can certainly do that; I don't know about
sendmail. (Anyway, it's not foolproof - there are all sorts of trivial
counter-examples - but it might help a bit.)

HTH,
 Richard

------------------------ MailScanner list ------------------------
To unsubscribe, email jiscmail at jiscmail.ac.uk with the words:
'leave mailscanner' in the body of the email.
Before posting, read the Wiki (http://wiki.mailscanner.info/) and
the archives (http://www.jiscmail.ac.uk/lists/mailscanner.html).

Support MailScanner development - buy the book off the website!




More information about the MailScanner mailing list