Chinaunix首页 | 论坛 | 博客
  • 博客访问: 511599
  • 博文数量: 53
  • 博客积分: 2265
  • 博客等级: 大尉
  • 技术积分: 574
  • 用 户 组: 普通用户
  • 注册时间: 2007-08-15 16:50
文章分类

全部博文(53)

文章存档

2019年(1)

2018年(2)

2016年(2)

2015年(1)

2014年(6)

2013年(5)

2012年(7)

2011年(16)

2010年(13)

分类: BSD

2015-11-17 11:12:27

由于message_size_limit = 50M是全局设置,针对每个用户的邮件大小(附件大小),如果要针对个别的用户,则需取消全局设置,而采用下面的设置。

但以下的做法有个弱点,就是接受邮件后,准备发送的时候才检测邮件的size大小,我们参考此方法,可以在ACL上做改进,在ACL上就可以优化服务器的负担,在用户一发送邮件时,就立刻检查邮件大小,而不是在发送后才检查。

----------------------------------------------------------------------
deny message =attachment oversize
        #domains = !+my_domains
        #senders =   name@mydomains.com
        condition = ${if > {$message_size}{${lookup{$local_part}lsearch{/etc/exim/messagelimit}{$value}{8M}}}{yes}{no}}
-------------------------------------------------------------------

/etc/exim/messagelimit 内容如下:
user1  10M
user2  20M
user3  30M

---------------------------------------------------------------------

ACL里面添加的意思是, 正常邮件(附件)的大小是8M, 如果超过8M,则拒绝发送。
如果要针对个别用户不同的邮件大小,在/etc/exim/messagelimit 里面的按格式,把用户添上,且指定大小。


Limit Email Size Per User In Exim

I’ve been searching on google for a while and found very few references regarding this, even in the exim user mailing list. Or its just me whose not lucky enough to get the answer. I finally stumbled on a post in a forum dated few years ago, explaining little script to get what I wanted to do, which hasn’t even been tested before. So I took the liberty to test that script on my working environment production. And now it worked beautifully just as I wanted.

Basically, you only need 2 steps to do this: add the code snippet; and create a file contains a list of users. Put this code inside the router section of your Exim config file:

    
reject_if_too_big:
driver = redirect
domains = customer.domain.com
condition = ${if > \
{$message_size}{${lookup{$local_part}lsearch{/etc/messagelimit}{$value}{5M}}}
\
{yes}{no}}
allow_fail
data = :fail: message too big.



Change the domain name and default value according to your need, and if you have a line that says:

    
message_size_limit = 50M

in your config file, comment that line out, because this could override the value settings in the script above. Save and restart Exim.

Next is to create a /etc/messagelimit file that contains all the users you want to give different size. Example:

    
user1  10M
user2  20M
user3  30M

This means all the users not listed in this file will only able to send or receive maximum 5MB email include the attachment. No need to restart Exim after adding or removing user to this file. Good luck!

来源:

阅读(1277) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~