added email validation
This commit is contained in:
parent
2566988f73
commit
5ed00e7269
|
@ -4,6 +4,7 @@ import logging
|
||||||
import email
|
import email
|
||||||
from email.header import decode_header
|
from email.header import decode_header
|
||||||
from email.Utils import parseaddr
|
from email.Utils import parseaddr
|
||||||
|
import re
|
||||||
#import requests
|
#import requests
|
||||||
import ConfigParser
|
import ConfigParser
|
||||||
import time
|
import time
|
||||||
|
@ -111,6 +112,9 @@ class CustomSMTPServer(smtpd.SMTPServer):
|
||||||
|
|
||||||
for em in rcpttos:
|
for em in rcpttos:
|
||||||
em = em.lower()
|
em = em.lower()
|
||||||
|
if not re.match(r"^[A-Za-z0-9\.\+_-]+@[A-Za-z0-9\._-]+\.[a-zA-Z]*$", em):
|
||||||
|
logger.exception('Invalid recipient: %s' % em)
|
||||||
|
continue
|
||||||
|
|
||||||
domain = em.split('@')[1]
|
domain = em.split('@')[1]
|
||||||
if(DISCARD_UNKNOWN and not domain in DOMAINS):
|
if(DISCARD_UNKNOWN and not domain in DOMAINS):
|
||||||
|
|
Loading…
Reference in a new issue