How can I prevent GMS from processing messages over a certain size?

  1. Home
  2. Knowledge Base
  3. GMS
  4. How can I prevent GMS from processing messages over a certain size?

Question

There are number of ways in which to accomplish this with each offering advantages and disadvantages over the other.

During an SMTP connection the sending client or server may optionally announce the estimated size of the message it is about to transmit. GMS can reject the message if the estimated size exceeds your pre-configured size restriction. This is particularly advantageous against large messages because they are blocked before any further physical DATA is pumped ‘down the wire’ saving valuable bandwidth. The disadvantage for this setting is that not all sending clients or servers will state the size of the message prior to transmitting. You can enable this within the GMS admin interface from Mail > Incoming > ESMTP > Allow Size.

A second option to accomplish this is to assign your local users to a profile and then configure this profile to reject incoming messages over a certain size. This option does not need to rely on the whether the sending party states the size of the message as the rejection is done at the point GMS receives all the DATA from the remote end. The disadvantage for this option is that the data is still transmitted down to the server and that these profile restrictions will only work against incoming messages, not outgoing.

A third option is to enable a setting with GMS Anti-Spam. Navigate to the domain level Anti Spam node, then find “Limits > Outbound Sizes”

Answer

There is a fourth option by way of a custom MML script but only customers running GMS Anti-Spam can benefit from this.

How it works:
If a message is received by your server (inbound or outbound) that is over 20MB’s in size (configurable from within the script), your server will return a protocol error, thus preventing delivery of the message.
It will also send off an e-mail to the postmaster account (again configurable) so that you know the e-mail address of the original sender of the rejected message.
To bypass these checks for a certain sender, change the e-mail address in the script under currently referencing ‘bypassaccount’.

Pre-installation notes:
Ensure that before the script goes live, you substitute any reference to ‘yourdomain.com’ with your correct domain name and change the 20485760 bytes (20MB) limit to a value of your liking.

Installation:
Please navigate to the system wide GMS Anti-Spam node and find “Scripts”. Add an End Of Message script. Give the script a name.
Paste in your code and then update the page.

sizeallowed = 20485760;
emailsize = emailsize;
sizeallowedint = toint(sizeallowed);
emailsizeint = toint(emailsize);

if (emailX-DetectLoop != 1 && mail != "bypassaccount@yourdomain.com")
{

 if (emailsizeint >= Sizeallowedint)
        {
         msg = msgcreate("null@yourdomain.com","postmaster@yourdomain.com",emailmail);

         if (msg)
              {
              msgAddHeader(msg,"X-DetectLoop","1");
              msgAddBody(msg,"Has tried to send a message exceeding your script limit.");
              msgClose(msg, msg_SEND);

               }

action =2;
parameter = "550 Message too large!";

          }
}

Keywords:mml size message attachment block reject outgoing esmtp script profile

Was this article helpful?

Related Articles