โฮสติ้ง จดโดเมน VPS

Short URL :

0087 | Mail limit per user on Directadmin

23/11/2009 ไอกอล์ฟ How to

Be Sociable, Share!

    เมื่อวาน มีน้องคนนึงถามว่า จะ limit email เฉพาะ user นั้นๆ ได้อย่างไร เอาเราก็เข้าไปคุ้ย ไปหาตั้งนานกว่าจะเจอ เลยขอ coppy มาเก็บไว้ใน Blog ซะหน่อย จะได้สะดวกเวลาค้นหา

    โดยทำการแก้ไขไฟล์ /etc/exim.pl ในส่วนของ check_limits

    sub check_limits
    {
            my $count = 0;
    
            #find the current user
            $uid = find_uid();
    
            if (uid_exempt($uid)) { return "yes"; }
    
            my $name = "";
            my $email_limit = 0;
            if (($name = getpwuid($uid))) {
    
                    if (-e "/etc/virtual/limit.$name") {
                            open (LIMIT, "/etc/virtual/limit.$name");
                            $email_limit = int(<LIMIT>);
                            close(LIMIT);
                    } else {
                            open (LIMIT, "/etc/virtual/limit");
                            $email_limit = int(<LIMIT>);
                            close(LIMIT);
                    }
    
                    if ($email_limit > 0) {
                            $count = (stat("/etc/virtual/usage/$name"))[7];
                            if ($count > $email_limit) {
                                    die("You ($name) have reach your daily email limit of $email_limit emails\n");
                            }
    
                            open (USAGE, ">>/etc/virtual/usage/$name");
                            print USAGE "1";
                            close (USAGE);
                            chmod (0660, "/etc/virtual/usage/$name");
                    }
            }
    
            my $sender_address = Exim::expand_string('$sender_address');
            my $mid = Exim::expand_string('$message_id');
    
            log_bandwidth($uid,"type=email&email=$sender_address&method=outgoing&id=$mid");
    
            return "yes"
    }
    

    เดิมจะตรวจสอบจาก /etc/virtual/limit แต่ที่เพิ่มคือให้เช็คแต่ละ user โดยต้องสร้างไฟล์ /etc/virtual/limit.USERNAME โดย USERNAME เป็นชื่อ user ของระบบ ถ้าไม่มีไฟล์ของ user นั้นๆ จะไปเรียกใช้ค่า global จาก /etc/virtual/limit แทน

    ที่มา : http://www.thaihosttalk.com/index.php?topic=18601.0

    Be Sociable, Share!

      directadmin mail limit

      Powered by WordPress. Designed by elogi.