Download Articles Stats About us Contact us
HomeVestaCP

Vestacp Exim Send Limit

ใส่ code นี้ใน /etc/exim/exim.conf
acl_not_smtp = acl_web_script
message_size_limit=20M

tls_advertise_hosts = *
tls_certificate = ${if exists{/etc/ssl/${tls_sni}.crt}{/etc/ssl/${tls_sni}.crt}{/usr/local/vesta/ssl/certificate.crt}}
tls_privatekey = ${if exists{/etc/ssl/${tls_sni}.key}{/etc/ssl/${tls_sni}.key}{/usr/local/vesta/ssl/certificate.key}}

 ...

begin acl

# เช็คอีเมล์ที่ส่งจาก script ใน server
# จำกัดการส่งเมล์ออกด้วย ratelimit ยกเว้นเมล์ที่ส่งโดย root
acl_web_script:

  deny    message       = 5k $authenticated_sender - $sender_address is sending too much emails limit: $sender_rate_limit ($acl_c_msg_limit / $sender_rate_period)
          set acl_c_msg_limit=${lookup{$sender_address_domain}nwildlsearch{/etc/exim/send_limits}}
          senders       = !*@ns1.palthai.com
          ratelimit     = $acl_c_msg_limit / 1d / strict / $sender_address_domain

  accept

# เช็คทั้งอีเมล์เข้าและออก
  acl_check_mail:

  deny    authenticated = *   # บังคับให้เช็คเฉพาะอีเมล์ออก
          message       = 7k $authenticated_sender - $sender_address is sending too much emails limit: $sender_rate_limit ($acl_c_msg_limit / $sender_rate_period)
          set acl_c_msg_limit=${lookup{$sender_address_domain}nwildlsearch{/etc/exim/send_limits}}
          ratelimit     = $acl_c_msg_limit / 1d / strict / $sender_address_domain

  accept

acl_check_rcpt:
  accept  hosts         = :

  deny    message       = Restricted characters in address
          domains       = +local_domains
          local_parts   = ^[.] : ^.*[@%!/|]

  deny    message       = Restricted characters in address
          domains       = !+local_domains
          local_parts   = ^[./|] : ^.*[@%!] : ^.*/\\.\\./

  drop  message = MULTIPLE_BOUNCE_RECIPIENTS
        senders = : postmaster@*
        condition = ${if >{$recipients_count}{0}{true}{false}}

# ป้องกัน การส่งเมล์หาที่อยุ่ที่ไม่มีอยู่จริง ซ้ำกันเกิน 10 ครั้งภายใน 1 วินาที
# พอพบว่าส่งมาแล้ว 2 ครั้งจะตัดการเชื่อมต่อ และยืดเวลาเช็คเมลครั้งละ 10 วินาที
  drop    message       = TOO_MANY_FAILED_RECIPIENTS
          log_message   = REJECTED - Too many failed recipients - count = $rcpt_fail_count
          condition     = ${if > {${eval:$rcpt_fail_count}}{2}{yes}{no}}
          !verify       = recipient/callout=2m,defer_ok,use_sender
          delay         = ${eval:$rcpt_fail_count*10}s

  require verify        = sender
สร้างไฟล์นี้ขึ้นมา /etc/exim/send_limits
# Commented lines and blank lines are ignored
# Format is     EMAIL: LIMIT

domain1.com: 20
domain2.com: 10

# Must be the last line, this is the default limit
*@*: 50
nano /usr/local/vesta/web/edit/server/exim/index.php
    // Update config
    ...

    // Update config1
    if ((empty($_SESSION['error_msg'])) && (!empty($_POST['v_config1']))) {
        $new_conf = '/etc/exim/send_limits';
        $fp = fopen($new_conf, 'w');
        fwrite($fp, str_replace("\r\n", "\n",  $_POST['v_config1']));
        fclose($fp);
    }

...

$v_config_path = '/etc/exim/exim.conf';
$v_config_path1 = '/etc/exim/send_limits';
$v_service_name = strtoupper('exim');

// Read config
$v_config = shell_exec(VESTA_CMD."v-open-fs-config ".$v_config_path);
if (!empty($v_config_path1)) $v_config1 = shell_exec(VESTA_CMD."v-open-fs-config ".$v_config_path1);
nano /usr/local/vesta/web/templates/admin/edit_server_service.html
                            <tr>
                                <td>
                                    <textarea class="vst-textinput console" name="v_config"><?=$v_config?></textarea>
                                </td>
                            </tr>

                            <?php if (!empty($v_config_path1)) { ?>
                            <tr>
                                <td class="vst-text step-top">
                                    <?=$v_config_path1 ?>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <textarea class="vst-textinput console" name="v_config1"><?=$v_config1?></textarea>
                                </td>
                            </tr>
                            <?php } ?>


26 ก.ค. 62
© 2000 - 2024 palthai.com. All rights reserved.