diff -urN ../exim-4.84.orig/src/globals.c ./src/globals.c --- ../exim-4.84.orig/src/globals.c 2014-08-29 21:03:53.000000000 +0300 +++ ./src/globals.c 2014-09-03 21:27:37.000000000 +0300 @@ -1204,7 +1204,8 @@ int smtp_accept_max = 20; int smtp_accept_max_nonmail= 10; uschar *smtp_accept_max_nonmail_hosts = US"*"; -int smtp_accept_max_per_connection = 1000; +//int smtp_accept_max_per_connection = 1000; +uschar *smtp_accept_max_per_connection = NULL; uschar *smtp_accept_max_per_host = NULL; int smtp_accept_queue = 0; int smtp_accept_queue_per_connection = 10; diff -urN ../exim-4.84.orig/src/globals.h ./src/globals.h --- ../exim-4.84.orig/src/globals.h 2014-08-09 15:44:29.000000000 +0300 +++ ./src/globals.h 2014-09-23 17:29:13.000000000 +0300 @@ -754,7 +754,8 @@ extern int smtp_accept_max; /* Max SMTP connections */ extern int smtp_accept_max_nonmail;/* Max non-mail commands in one con */ extern uschar *smtp_accept_max_nonmail_hosts; /* Limit non-mail cmds from these hosts */ -extern int smtp_accept_max_per_connection; /* Max msgs per connection */ +//extern int smtp_accept_max_per_connection; /* Max msgs per connection */ +extern uschar *smtp_accept_max_per_connection; /* Max msgs per connection */ extern uschar *smtp_accept_max_per_host; /* Max SMTP cons from one IP addr */ extern int smtp_accept_queue; /* Queue after so many connections */ extern int smtp_accept_queue_per_connection; /* Queue after so many msgs */ diff -urN ../exim-4.84.orig/src/readconf.c ./src/readconf.c --- ../exim-4.84.orig/src/readconf.c 2014-08-09 15:44:29.000000000 +0300 +++ ./src/readconf.c 2014-10-02 18:52:32.000000000 +0300 @@ -373,7 +373,7 @@ { "smtp_accept_max", opt_int, &smtp_accept_max }, { "smtp_accept_max_nonmail", opt_int, &smtp_accept_max_nonmail }, { "smtp_accept_max_nonmail_hosts", opt_stringptr, &smtp_accept_max_nonmail_hosts }, - { "smtp_accept_max_per_connection", opt_int, &smtp_accept_max_per_connection }, + { "smtp_accept_max_per_connection", opt_stringptr, &smtp_accept_max_per_connection }, { "smtp_accept_max_per_host", opt_stringptr, &smtp_accept_max_per_host }, { "smtp_accept_queue", opt_int, &smtp_accept_queue }, { "smtp_accept_queue_per_connection", opt_int, &smtp_accept_queue_per_connection }, diff -urN ../exim-4.84.orig/src/smtp_in.c ./src/smtp_in.c --- ../exim-4.84.orig/src/smtp_in.c 2014-09-03 21:14:52.000000000 +0300 +++ ./src/smtp_in.c 2014-09-23 17:18:39.000000000 +0300 @@ -3776,8 +3776,36 @@ /* Check to see if the limit for messages per connection would be exceeded by accepting further messages. */ - if (smtp_accept_max_per_connection > 0 && - smtp_mailcmd_count > smtp_accept_max_per_connection) + +int accept_max_per_connection = -1; +if (smtp_accept_max_per_connection != NULL) + { + uschar *expanded = expand_string(smtp_accept_max_per_connection); + if (expanded == NULL) + { + if (!expand_string_forcedfail) + log_write(0, LOG_MAIN|LOG_PANIC, "expansion of smtp_accept_max_per_connection " + "failed for message from %s: %s", host_and_ident(FALSE), expand_string_message); + } + /* For speed, interpret a decimal number inline here */ + else + { + accept_max_per_connection = 0; + uschar *s = expanded; + while (isdigit(*s)) + accept_max_per_connection = accept_max_per_connection * 10 + *s++ - '0'; + if (*s != 0) + log_write(0, LOG_MAIN|LOG_PANIC, "expansion of smtp_accept_max_per_connection " + "for message from %s contains non-digit: %s", host_and_ident(FALSE), expanded); + } + } +if (accept_max_per_connection == -1) accept_max_per_connection = 1000; + + +// if (smtp_accept_max_per_connection > 0 && +// smtp_mailcmd_count > smtp_accept_max_per_connection) + if (accept_max_per_connection > 0 && + smtp_mailcmd_count > accept_max_per_connection) { smtp_printf("421 too many messages in this connection\r\n"); log_write(0, LOG_MAIN|LOG_REJECT, "rejected MAIL command %s: too many "