internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: Mailu/Mailu

Issue:
Manage user authentication and permissions
Currently no authentication is implemented. Multiple issues will have to be tackled:
- complete permission scheme or simple admin role plus admins per domain?
- how to store user passwords (shared format between Flask-admin and dovecot)?
- how should the initial use be created?



Discussion:
Fixed by 4576e1f5c2bd8fbdd8c706f435c9e4718dbc384d.


Resolving patch:
diff --git a/core/admin/start.py b/core/admin/start.py
--- a/core/admin/start.py
+++ b/core/admin/start.py
@@ -35,7 +35,7 @@ def test_DNS():
         resolver.nameservers=[ns]
         while True:
             try:
-                result = resolver.query('example.org', dns.rdatatype.A, dns.rdataclass.IN, lifetime=10)
+                result = resolver.resolve('example.org', dns.rdatatype.A, dns.rdataclass.IN, lifetime=10)
             except Exception as e:
                 log.critical("Your DNS resolver at %s is not working (%s). Please use another resolver or enable unbound via https://setup.mailu.io.", ns, e);
             else:


Test patch:
Repository: Mailu/Mailu

Issue:
max attachement size with rainloop is 1mb
## Environment & Versions
### Environment
 - [x] docker-compose
 - [ ] kubernetes
 - [ ] docker swarm

### Versions
1.9

## Description
cannot attach anything larger then 1,048,300 bytes to any email from rainloop

## Replication Steps
attach anything larger then 1,048,300 bytes to any email from rainloop and it will fails with http 413

## Expected behaviour
i can attach any file as large as the MESSAGE_SIZE_LIMIT as defined in (mailu.env - 33%)

## Logs
browser log only: for the xhr POST
````markdown
```
413 Request Entity Too Large
```
````



Discussion:
Good day please see the comment in this pool request: https://github.com/Mailu/Mailu/pull/2149#issuecomment-1021784532

This explains that something needs to be changed also in the webmail container

Resolving patch:
diff --git a/webmails/rainloop/config.py b/webmails/rainloop/config.py
new file mode 100755
--- /dev/null
+++ b/webmails/rainloop/config.py
@@ -0,0 +1,15 @@
+#!/usr/bin/python3
+
+import os
+import logging as log
+import sys
+from socrate import system, conf
+
+args = os.environ.copy()
+
+log.basicConfig(stream=sys.stderr, level=args.get("LOG_LEVEL", "WARNING"))
+
+# Build final configuration paths
+conf.jinja("/config/nginx-rainloop.conf", args, "/etc/nginx/http.d/rainloop.conf")
+if os.path.exists("/var/run/nginx.pid"):
+    os.system("nginx -s reload")
diff --git a/webmails/rainloop/start.py b/webmails/rainloop/start.py
--- a/webmails/rainloop/start.py
+++ b/webmails/rainloop/start.py
@@ -4,6 +4,7 @@
 import shutil
 import logging as log
 import sys
+import subprocess
 from socrate import system, conf
 
 log.basicConfig(stream=sys.stderr, level=os.environ.get("LOG_LEVEL", "WARNING"))
@@ -22,8 +23,11 @@
 conf.jinja("/defaults/default.ini", os.environ, "/data/_data_/_default_/domains/default.ini")
 conf.jinja("/defaults/application.ini", os.environ, "/data/_data_/_default_/configs/application.ini")
 conf.jinja("/defaults/php.ini", os.environ, "/etc/php7/php.ini")
+# Start the fastcgi process manager now that config files have been adjusted
+os.system("php-fpm7")
 
 os.system("chown -R nginx:nginx /data")
 os.system("chmod -R a+rX /var/www/rainloop/")
 
+subprocess.call(["/config.py"])
 os.execv("/usr/sbin/nginx", ["nginx", "-g", "daemon off;"])


Test patch:
Repository: Mailu/Mailu

Issue:
Provide a "slow" transport for Postfix
## Environment & Versions
### Environment
 - [x] docker-compose
 - [ ] kubernetes
 - [ ] docker swarm

### Versions
1.9

## Description
Orange, a mainstream french ISP, and a few others, have a rate limit : without a slow transport, I get deferred messages with this : "Too many connections, slow down." It is a known issue https://blog.network-studio.fr/2011/06/30/too-many-connections-slow-down/

I managed to get it done with the overrides/ files :

overrides/postfix.cf :

```
transport_maps = socketmap:unix:/tmp/podop.socket:transport lmdb:/etc/postfix/transport.map

slow_destination_concurrency_limit = 1
slow_destination_recipient_limit = 20
slow_destination_rate_delay = 5s
slow_destination_concurrency_failed_cohort_limit=10

```
overrides/postfix.master :

```
slow/unix= slow unix - - n - 5 smtp -o syslog_name=postfix-slow
```

overrides/transport.map :

```
wanadoo.com slow:
wanadoo.fr slow:
orange.com slow:
orange.fr slow:
laposte.net slow:
free.fr slow:
hotmail.fr slow:
outlook.fr slow:
yahoo.fr slow:
```
I did not have time to fully test it, but it seems to work. Configuration values may need a fine tuning...

It would be nice to have such "slow" transport built in in Mailu, with an override possibility to edit the domain list.


Discussion:

Resolving patch:
diff --git a/core/postfix/start.py b/core/postfix/start.py
--- a/core/postfix/start.py
+++ b/core/postfix/start.py
@@ -74,9 +74,10 @@ def is_valid_postconf_line(line):
 else:
     conf.jinja("/conf/mta-sts-daemon.yml", os.environ, "/etc/mta-sts-daemon.yml")
 
-if not os.path.exists("/etc/postfix/tls_policy.map.lmdb"):
-    open("/etc/postfix/tls_policy.map", "a").close()
-    os.system("postmap /etc/postfix/tls_policy.map")
+for policy in ['tls_policy', 'transport']:
+    if not os.path.exists(f'/etc/postfix/{policy}.map.lmdb'):
+        open(f'/etc/postfix/{policy}.map', 'a').close()
+        os.system(f'postmap /etc/postfix/{policy}.map')
 
 if "RELAYUSER" in os.environ:
     path = "/etc/postfix/sasl_passwd"


Test patch:
Repository: Mailu/Mailu

Issue:
Deprecate (and remove) POD_ADDRESS_RANGE
As discussed in #1209, POD_ADDRESS_RANGE should be removed and SUBNET should be used instead.
Tasks:
- remove all occurences of POD_ADDRESS_RANGE from containers
- update the docs
- write a changelog (breaking change!)


Discussion:
Hi There,

The `Mailu`-Project is currently in a bit of a bind! We are short on man-power, and we need to judge if it is possible for us to put in some work on this issue.

To help with that, we are currently trying to find out which issues are actively keeping users from using `Mailu`, which issues have someone who want to work on them — and which issues may be less important. These a less important ones could be discarded for the time being, until the project is in a more stable and regular state once again.

In order for us to better assess this, it would be helpful if you could put a **reaction on this post** (use the :smiley: icon to the top-right).
- 👍️ if you **need this** to be able to use Mailu. Ideally, you’d also be able to test this on your installation, and provide feedback …
- 🎉 if you find it a **nice bonus**, but no deal-breaker
- 🚀 if you want to **work on it yourself**!
We want to keep this **voting open for 2 weeks** from now, so please help out!

Resolving patch:
diff --git a/core/admin/mailu/configuration.py b/core/admin/mailu/configuration.py
--- a/core/admin/mailu/configuration.py
+++ b/core/admin/mailu/configuration.py
@@ -87,8 +87,7 @@
     'HOST_REDIS': 'redis',
     'HOST_FRONT': 'front',
     'SUBNET': '192.168.203.0/24',
-    'SUBNET6': None,
-    'POD_ADDRESS_RANGE': None
+    'SUBNET6': None
 }
 
 class ConfigManager:
diff --git a/core/admin/mailu/internal/views/dovecot.py b/core/admin/mailu/internal/views/dovecot.py
--- a/core/admin/mailu/internal/views/dovecot.py
+++ b/core/admin/mailu/internal/views/dovecot.py
@@ -13,8 +13,6 @@ def dovecot_passdb_dict(user_email):
     allow_nets.append(app.config["SUBNET"])
     if app.config["SUBNET6"]:
         allow_nets.append(app.config["SUBNET6"])
-    if app.config["POD_ADDRESS_RANGE"]:
-        allow_nets.append(app.config["POD_ADDRESS_RANGE"])
     return flask.jsonify({
         "password": None,
         "nopassword": "Y",


Test patch:
Repository: Mailu/Mailu

Issue:
Include start and end dates in the auto-reply period
<!--

Thank you for opening an issue with Mailu. Please understand that issues are meant for bugs and enhancement-requests.
For **user-support questions**, reach out to us  on [matrix](https://matrix.to/#/#mailu:tedomum.net).

To be able to help you best, we need some more information.

Before you open your issue
- Check if no issue or pull-request for this already exists.
- Check [documentation](https://mailu.io/master/) and [FAQ](https://mailu.io/master/faq.html). (Tip, use the search function on the documentation page)
- You understand `Mailu` is made by volunteers in their **free time** — be concise, civil and accept that delays can occur.
- The title of the issue should be short and simple. It should contain specific terms related to the actual issue. Be specific while writing the title.

Please put your text outside of the comment blocks to be visible. You can use the button "Preview" above to check.

-->

## Environment & Version

### Environment

- [X] docker-compose
- [ ] kubernetes
- [ ] docker swarm

### Version

- Version: `1.9`

## Description
The administration interface provides an [auto-reply](https://mailu.io/master/webadministration.html#auto-reply) page where automatic replies can be configured with start and end dates. Unfortunately both the start date and the end date are not included in the auto-reply period (i.e. no auto replies are being sent on these two days). To work around this issue you have to insert the day before your vacation as start date and the day after your vacation as end date. This is not intuitive.

## Replication Steps
Activate the auto-reply feature, insert subject and body text and the current date as "start of vacation" ("end of vacation" has to be a date in the future). Then send an email from another email account (external) to your email address hosted on Mailu.

## Observed behaviour
No auto reply message received by the sender.

## Expected behaviour
Auto reply message received by the sender.

To verify this behaviour you can add yesterday's date as "start of vacation" date and send another email to your Mailu account ... the sender will receive an auto reply message ... 
The same applies to the "end of vacation" date.

## Logs
n/a



Discussion:

Resolving patch:
diff --git a/core/admin/mailu/models.py b/core/admin/mailu/models.py
--- a/core/admin/mailu/models.py
+++ b/core/admin/mailu/models.py
@@ -546,8 +546,8 @@ def reply_active(self):
         now = date.today()
         return (
             self.reply_enabled and
-            self.reply_startdate < now and
-            self.reply_enddate > now
+            self.reply_startdate <= now and
+            self.reply_enddate >= now
         )
 
     @property


Test patch:
Repository: Mailu/Mailu

Issue:
not allowing POP3/IMAP leads to infinite loop in webmail
v1.9.32

I noticed a small bug. If both are disabled, webmail is stuck in an infinite loop. I guess nobody ever tried it before since both are checked by default.

Not very consequential, but I figured you might want to know. Not sure about the use case either. I unchecked them because there was no need for this particular account and found it that way.

Cheers


Discussion:
Thanks. Logs show this (over and over again):
```
mailu-front-1  | * - - [14/Sep/2022:13:46:43 +0000] "GET /webmail/sso.php HTTP/2.0" 302 0 "https://domain.fqdn/sso/login" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:104.0) Gecko/20100101 Firefox/104.0"
mailu-front-1  | 2022/09/14 13:46:43 [info] 10#10: *1372 client 192.168.203.10:38486 connected to 0.0.0.0:10143
mailu-front-1  | 2022/09/14 13:46:43 [info] 10#10: *1372 client login failed: "Authentication credentials invalid" while in http auth state, client: 192.168.203.10, server: 0.0.0.0:10143, login: "disabled@example.com"
```

Resolving patch:
diff --git a/core/admin/mailu/internal/nginx.py b/core/admin/mailu/internal/nginx.py
--- a/core/admin/mailu/internal/nginx.py
+++ b/core/admin/mailu/internal/nginx.py
@@ -26,12 +26,14 @@
     }),
 }
 
+WEBMAIL_PORTS = ['10143', '10025']
+
 def check_credentials(user, password, ip, protocol=None, auth_port=None):
-    if not user or not user.enabled or (protocol == "imap" and not user.enable_imap) or (protocol == "pop3" and not user.enable_pop):
+    if not user or not user.enabled or (protocol == "imap" and not user.enable_imap and not auth_port in WEBMAIL_PORTS) or (protocol == "pop3" and not user.enable_pop):
         return False
     is_ok = False
     # webmails
-    if auth_port in ['10143', '10025'] and password.startswith('token-'):
+    if auth_port in WEBMAIL_PORTS and password.startswith('token-'):
         if utils.verify_temp_token(user.get_id(), password):
             is_ok = True
     # All tokens are 32 characters hex lowercase


Test patch:
Repository: Mailu/Mailu

Issue:
not allowing POP3/IMAP leads to infinite loop in webmail
v1.9.32

I noticed a small bug. If both are disabled, webmail is stuck in an infinite loop. I guess nobody ever tried it before since both are checked by default.

Not very consequential, but I figured you might want to know. Not sure about the use case either. I unchecked them because there was no need for this particular account and found it that way.

Cheers


Discussion:
Thanks. Logs show this (over and over again):
```
mailu-front-1  | * - - [14/Sep/2022:13:46:43 +0000] "GET /webmail/sso.php HTTP/2.0" 302 0 "https://domain.fqdn/sso/login" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:104.0) Gecko/20100101 Firefox/104.0"
mailu-front-1  | 2022/09/14 13:46:43 [info] 10#10: *1372 client 192.168.203.10:38486 connected to 0.0.0.0:10143
mailu-front-1  | 2022/09/14 13:46:43 [info] 10#10: *1372 client login failed: "Authentication credentials invalid" while in http auth state, client: 192.168.203.10, server: 0.0.0.0:10143, login: "disabled@example.com"
```

Resolving patch:
diff --git a/core/admin/mailu/internal/nginx.py b/core/admin/mailu/internal/nginx.py
--- a/core/admin/mailu/internal/nginx.py
+++ b/core/admin/mailu/internal/nginx.py
@@ -27,12 +27,14 @@
     }),
 }
 
+WEBMAIL_PORTS = ['10143', '10025']
+
 def check_credentials(user, password, ip, protocol=None, auth_port=None):
-    if not user or not user.enabled or (protocol == "imap" and not user.enable_imap) or (protocol == "pop3" and not user.enable_pop):
+    if not user or not user.enabled or (protocol == "imap" and not user.enable_imap and not auth_port in WEBMAIL_PORTS) or (protocol == "pop3" and not user.enable_pop):
         return False
     is_ok = False
     # webmails
-    if auth_port in ['10143', '10025'] and password.startswith('token-'):
+    if auth_port in WEBMAIL_PORTS and password.startswith('token-'):
         if utils.verify_temp_token(user.get_id(), password):
             is_ok = True
     # All tokens are 32 characters hex lowercase


Test patch:
Repository: Mailu/Mailu

Issue:
Docker container crashes if IPv6 is disabled at the system level.
If listen [::] is found somewhere in the configs, but IPv6 is disabled at the host system level and in the docker, then the process crashes, and, accordingly, the docker container also crashes.

This can be manually climbed into each container, corrected, but it is not very convenient.

docker exec mailu_front_1 sed -i '/listen \[/d' /conf/nginx.conf
docker exec mailu_front_1 sed -i '/listen \[/d' /etc/nginx/nginx.conf
docker exec mailu_front_1 sed -i '/listen \[/d' /etc/nginx/http.d/default.conf
docker restart mailu_front_1

docker restart mailu_webdav_1 && docker exec -it mailu_webdav_1 sed -i 's/hosts =.*\[::\].*/hosts = 0.0.0.0:5232/g' /radicale.conf && docker restart mailu_webdav_1


Can you add a container launch option to remove listen [::] from configs?


Discussion:

Resolving patch:
diff --git a/core/admin/start.py b/core/admin/start.py
--- a/core/admin/start.py
+++ b/core/admin/start.py
@@ -52,15 +52,21 @@ def test_DNS():
 
 test_DNS()
 
-start_command=" ".join([
-    "gunicorn",
-    f"--threads {str(os.cpu_count())}",
-    "-b :80",
+cmdline = [
+	"gunicorn",
+	"--threads", f"{os.cpu_count()}",
+	# If SUBNET6 is defined, gunicorn must listen on IPv6 as well as IPv4
+	"-b", f"{'[::]' if os.environ.get('SUBNET6') else ''}:80",
     "--logger-class mailu.Logger",
     "--worker-tmp-dir /dev/shm",
-    "--access-logfile -" if (log.root.level<=log.INFO) else "",
-    "--error-logfile -",
-    "--preload",
-    "'mailu:create_app()'"])
+	"--error-logfile", "-",
+	"--preload"
+]
 
-os.system(start_command)
+# logging
+if log.root.level <= log.INFO:
+	cmdline.extend(["--access-logfile", "-"])
+
+cmdline.append("'mailu:create_app()'")
+
+os.system(" ".join(cmdline))


Test patch:
Repository: Mailu/Mailu

Issue:
Small feature - add mailu version in the admin UI 
Add mailu version in the admin UI 
I think it would nice to be able to see which version of mailu we are running, unless there is other simple way?

Thanks


Discussion:
If you run a recent-enough version of Mailu you can use:
``docker-compose exec admin cat /version`` or should be able to see which image are running using ``docker ps``.
I suggest a different approach altogether.

Broken updates have caused me great pain several times in years past. I was only saved by luck, since I hadn't updated in a while, and a new major release was available that fixed it. (God forbid you get stuck at the wrong time!) That's because you used to not be able to select specific versions. That changed a while ago. Now you can override it by setting an environment variable.

I simply made a small update script:
```bash
export MAILU_VERSION=1.9.43
docker compose pull
docker compose down
docker compose up -d --force-recreate
docker compose logs -f
```

The additional `down` is probably overkill, but some earlier releases had issues when not fully down-ed, so I kept it.

It sounds like you update automatically, I'd personally recommend against that. Hence the logs line. I want to do a sanity check before considering it done.

How to find a changelog is explained on the release page. I'm guilty of not always reading it myself, though. :)

Cheers

Resolving patch:
diff --git a/core/admin/mailu/configuration.py b/core/admin/mailu/configuration.py
--- a/core/admin/mailu/configuration.py
+++ b/core/admin/mailu/configuration.py
@@ -18,6 +18,7 @@
     'TEMPLATES_AUTO_RELOAD': True,
     'MEMORY_SESSIONS': False,
     'FETCHMAIL_ENABLED': True,
+    'MAILU_VERSION': 'unknown',
     # Database settings
     'DB_FLAVOR': None,
     'DB_USER': 'mailu',
@@ -157,6 +158,10 @@ def init_app(self, app):
         self.config['HOSTNAME'] = hostnames[0]
         self.config['DEFAULT_SPAM_THRESHOLD'] = int(self.config['DEFAULT_SPAM_THRESHOLD'])
         self.config['PROXY_AUTH_WHITELIST'] = set(ipaddress.ip_network(cidr, False) for cidr in (cidr.strip() for cidr in self.config['PROXY_AUTH_WHITELIST'].split(',')) if cidr)
+        try:
+            self.config['MAILU_VERSION'] = open('/version', 'r').read()
+        except FileNotFoundError:
+            pass
 
         # update the app config
         app.config.update(self.config)


Test patch:
Repository: Mailu/Mailu

Issue:
plus mail in auto-forward destination
The email address in `admin -> User settings -> Auto-forward -> Destination` cannot contains a '+' character (error: Invalid email address). But the '+' in email address is valid and admin should accept it.


Discussion:
This is a pretty straightforward bug probably related to flask form validation
Hi There,

The `Mailu`-Project is currently in a bit of a bind! We are short on man-power, and we need to judge if it is possible for us to put in some work on this issue.

To help with that, we are currently trying to find out which issues are actively keeping users from using `Mailu`, which issues have someone who want to work on them — and which issues may be less important. These a less important ones could be discarded for the time being, until the project is in a more stable and regular state once again.

In order for us to better assess this, it would be helpful if you could put a **reaction on this post** (use the :smiley: icon to the top-right).
- 👍️ if you **need this** to be able to use Mailu. Ideally, you’d also be able to test this on your installation, and provide feedback …
- 🎉 if you find it a **nice bonus**, but no deal-breaker
- 🚀 if you want to **work on it yourself**!
We want to keep this **voting open for 2 weeks** from now, so please help out!
The problem is probably here:
https://github.com/Mailu/Mailu/blob/dbbfa44461c3b8a537e9fe6b56f4690417d3c8a2/core/admin/mailu/ui/forms.py#L40
This is the validator for the forward field
https://github.com/Mailu/Mailu/blob/dbbfa44461c3b8a537e9fe6b56f4690417d3c8a2/core/admin/mailu/ui/forms.py#L106

I think it can be fixed with this regex
```^([+_a-z0-9\-]+)(\.[+_a-z0-9\-]+)*@([a-z0-9\-]{2,}\.)*([a-z]{2,})(,([+_a-z0-9\-]+)(\.[+_a-z0-9\-]+)*@([a-z0-9\-]{2,}\.)*([a-z]{2,}))*$```
According to https://regex101.com/ the regex works.


Resolving patch:
diff --git a/core/admin/mailu/ui/forms.py b/core/admin/mailu/ui/forms.py
--- a/core/admin/mailu/ui/forms.py
+++ b/core/admin/mailu/ui/forms.py
@@ -37,7 +37,7 @@ def __init__(self,message=_('Invalid email address.')):
         self.message = message
 
     def __call__(self, form, field):
-        pattern = re.compile(r'^([_a-z0-9\-]+)(\.[_a-z0-9\-]+)*@([a-z0-9\-]{1,}\.)*([a-z]{1,})(,([_a-z0-9\-]+)(\.[_a-z0-9\-]+)*@([a-z0-9\-]{1,}\.)*([a-z]{2,}))*$')
+        pattern = re.compile(r'^([_a-z0-9\-\+]+)(\.[_a-z0-9\-\+]+)*@([a-z0-9\-]{1,}\.)*([a-z]{1,})(,([_a-z0-9\-\+]+)(\.[_a-z0-9\-\+]+)*@([a-z0-9\-]{1,}\.)*([a-z]{2,}))*$')
         if not pattern.match(field.data.replace(" ", "")):
             raise validators.ValidationError(self.message)
 


Test patch:
Repository: Mailu/Mailu

Issue:
plus mail in auto-forward destination
The email address in `admin -> User settings -> Auto-forward -> Destination` cannot contains a '+' character (error: Invalid email address). But the '+' in email address is valid and admin should accept it.


Discussion:
This is a pretty straightforward bug probably related to flask form validation
Hi There,

The `Mailu`-Project is currently in a bit of a bind! We are short on man-power, and we need to judge if it is possible for us to put in some work on this issue.

To help with that, we are currently trying to find out which issues are actively keeping users from using `Mailu`, which issues have someone who want to work on them — and which issues may be less important. These a less important ones could be discarded for the time being, until the project is in a more stable and regular state once again.

In order for us to better assess this, it would be helpful if you could put a **reaction on this post** (use the :smiley: icon to the top-right).
- 👍️ if you **need this** to be able to use Mailu. Ideally, you’d also be able to test this on your installation, and provide feedback …
- 🎉 if you find it a **nice bonus**, but no deal-breaker
- 🚀 if you want to **work on it yourself**!
We want to keep this **voting open for 2 weeks** from now, so please help out!
The problem is probably here:
https://github.com/Mailu/Mailu/blob/dbbfa44461c3b8a537e9fe6b56f4690417d3c8a2/core/admin/mailu/ui/forms.py#L40
This is the validator for the forward field
https://github.com/Mailu/Mailu/blob/dbbfa44461c3b8a537e9fe6b56f4690417d3c8a2/core/admin/mailu/ui/forms.py#L106

I think it can be fixed with this regex
```^([+_a-z0-9\-]+)(\.[+_a-z0-9\-]+)*@([a-z0-9\-]{2,}\.)*([a-z]{2,})(,([+_a-z0-9\-]+)(\.[+_a-z0-9\-]+)*@([a-z0-9\-]{2,}\.)*([a-z]{2,}))*$```
According to https://regex101.com/ the regex works.


Resolving patch:
diff --git a/core/admin/mailu/ui/forms.py b/core/admin/mailu/ui/forms.py
--- a/core/admin/mailu/ui/forms.py
+++ b/core/admin/mailu/ui/forms.py
@@ -37,7 +37,7 @@ def __init__(self,message=_('Invalid email address.')):
         self.message = message
 
     def __call__(self, form, field):
-        pattern = re.compile(r'^([_a-z0-9\-]+)(\.[_a-z0-9\-]+)*@([a-z0-9\-]{2,}\.)*([a-z]{2,})(,([_a-z0-9\-]+)(\.[_a-z0-9\-]+)*@([a-z0-9\-]{2,}\.)*([a-z]{2,}))*$')
+        pattern = re.compile(r'^([_a-z0-9\-\+]+)(\.[_a-z0-9\-\+]+)*@([a-z0-9\-]{1,}\.)*([a-z]{1,})(,([_a-z0-9\-\+]+)(\.[_a-z0-9\-\+]+)*@([a-z0-9\-]{1,}\.)*([a-z]{2,}))*$')
         if not pattern.match(field.data.replace(" ", "")):
             raise validators.ValidationError(self.message)
 


Test patch: