permit sending mail with attachement


Apr 19, 2006
hi there,

Need help. I have 7 domains on my box and I need to set 1 domain not to send out any mail with attachment. Any tips or links to guide me in doing the task?

Thanks in advance


Well-Known Member
Jun 19, 2005
1. set below option in the first part of your exim.conf file

message_size_limit = 10M

above setting would restrict incoming as well as outgoing at 10MB.

Antoher method which is not tested in live environment, If you want to restrict size of message per domain basis, you could follow the given steps as below:

Create a file to store the size limits for each domain that you wish to limit the message size. Use wildcard (*) for limiting the message size for all the domains not contained in the file.

# cat > /etc/mail/msg-size-limits 
domain1.tld: 10M 
domain2.tld: 20M 
*: 5M 
As per the above, we are restricting domain1 at 10MB, domain2 at 20MB and all other domains at 5MB

b. Create another file and store the messages which should return to the sender of the large message.

# cat > /etc/mail/msg-size-limit-messages
domain2.tld: You are trying to send a message which is $message_size \
             in size. This is larger than your maximum message size limit \
             of ${expand:${lookup{$domain}lsearch*@{/etc/mail/msg-size-limits}}}.
*: The largest acceptable message size for $domain is \
   Your message size was $message_size. Please revise your message so it \
   does not exceed this maximum file size and resend. If this is not \
   possible, contact the recipient in another way.
Note that domain names contained in first file maybe omitted in the second file and vice-versa. The omitted domains will be taken care by the wildcard (*) entry.

c. Add the following code in the Routers section of your Exim configuration file.
(Please note that ORDER in which you place your routers in this section DOES matter and that is exactly what needs to be tested practically and thoroughly even). I think it will go in the 7th box in the WHM editor of Exim config file.

driver = redirect
domains = +local_domains : \
condition = ${if >{$message_size}{${expand:${lookup{$domain}lsearch*@{/etc/mail/msg-size-limits}}}} {yes}{no}}
data = :fail: \

* Please ignore the space in between "lsearch*@{"