mirror of
https://github.com/Mailu/Mailu.git
synced 2025-05-27 22:57:38 +02:00
Merge #3057
3057: Retry up to 5 times if not ready r=mergify[bot] a=nextgens Add retry logic to ensure we don't always pass if clamav is not ready; return a 25 error only if it's a permanent rejection code so that we can differentiate in between "definitely reject" and "was rejected because of a glitch" Co-authored-by: Florent Daigniere <nextgens@freenetproject.org>
This commit is contained in:
commit
42db941fa9
@ -1,7 +1,7 @@
|
|||||||
# GTUBE should be blocked, see https://rspamd.com/doc/gtube_patterns.html
|
# GTUBE should be blocked, see https://rspamd.com/doc/gtube_patterns.html
|
||||||
python3 tests/email_test.py "XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X"
|
python3 tests/email_test.py "XJS*C4JDBQADN1.NSBN3*2IDNEN*GTUBE-STANDARD-ANTI-UBE-TEST-EMAIL*C.34X"
|
||||||
if [ $? -eq 25 ]; then
|
if [ $? -ne 25 ]; then
|
||||||
exit 0
|
|
||||||
else
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
@ -21,19 +21,31 @@ if len(sys.argv) == 3:
|
|||||||
part.add_header('Content-Disposition', "attachment; filename=%s" % ntpath.basename(sys.argv[2]))
|
part.add_header('Content-Disposition', "attachment; filename=%s" % ntpath.basename(sys.argv[2]))
|
||||||
msg.attach(part)
|
msg.attach(part)
|
||||||
|
|
||||||
try:
|
for i in range(5):
|
||||||
smtp_server = smtplib.SMTP('localhost')
|
try:
|
||||||
smtp_server.set_debuglevel(1)
|
smtp_server = smtplib.SMTP('localhost')
|
||||||
smtp_server.connect('localhost', 587)
|
smtp_server.set_debuglevel(1)
|
||||||
smtp_server.ehlo()
|
smtp_server.connect('localhost', 587)
|
||||||
smtp_server.starttls()
|
smtp_server.ehlo()
|
||||||
smtp_server.ehlo()
|
smtp_server.starttls()
|
||||||
smtp_server.login("admin@mailu.io", "password")
|
smtp_server.ehlo()
|
||||||
|
smtp_server.login("admin@mailu.io", "password")
|
||||||
|
|
||||||
smtp_server.sendmail("admin@mailu.io", "user@mailu.io", msg.as_string())
|
smtp_server.sendmail("admin@mailu.io", "user@mailu.io", msg.as_string())
|
||||||
smtp_server.quit()
|
smtp_server.quit()
|
||||||
except:
|
except smtplib.SMTPRecipientsRefused:
|
||||||
sys.exit(25)
|
sys.exit(25)
|
||||||
|
except smtplib.SMTPDataError as e:
|
||||||
|
if e.smtp_code == 451:
|
||||||
|
print(f"Not ready attempt {i}")
|
||||||
|
time.sleep(5)
|
||||||
|
continue
|
||||||
|
if e.smtp_code >= 500 and e.smtp_code <600:
|
||||||
|
sys.exit(25)
|
||||||
|
sys.exit(2525)
|
||||||
|
except:
|
||||||
|
sys.exit(2525)
|
||||||
|
break
|
||||||
|
|
||||||
time.sleep(30)
|
time.sleep(30)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user