mirror of
https://github.com/mail-in-a-box/mailinabox.git
synced 2026-03-04 15:54:48 +01:00
various fixes; rewrote test scripts
This commit is contained in:
15
tests/imap.py
Normal file → Executable file
15
tests/imap.py
Normal file → Executable file
@@ -1,11 +1,16 @@
|
||||
import imaplib, os
|
||||
#!/usr/bin/python3
|
||||
import imaplib, sys
|
||||
|
||||
username = "testuser@" + os.environ.get("DOMAIN", "testdomain.com")
|
||||
if len(sys.argv) < 3:
|
||||
print("Usage: tests/imap.py host username password")
|
||||
sys.exit(1)
|
||||
|
||||
M = imaplib.IMAP4_SSL(os.environ["INSTANCE_IP"])
|
||||
M.login(username, "testpw")
|
||||
M.select()
|
||||
host, username, pw = sys.argv[1:4]
|
||||
|
||||
M = imaplib.IMAP4_SSL(host)
|
||||
M.login(username, pw)
|
||||
print("Login successful.")
|
||||
M.select()
|
||||
typ, data = M.search(None, 'ALL')
|
||||
for num in data[0].split():
|
||||
typ, data = M.fetch(num, '(RFC822)')
|
||||
|
||||
18
tests/smtp_submission.py
Normal file → Executable file
18
tests/smtp_submission.py
Normal file → Executable file
@@ -1,16 +1,22 @@
|
||||
import smtplib, sys, os
|
||||
#!/usr/bin/python3
|
||||
import smtplib, sys
|
||||
|
||||
fromaddr = "testuser@" + os.environ.get("DOMAIN", "testdomain.com")
|
||||
if len(sys.argv) < 3:
|
||||
print("Usage: tests/smtp_submission.py host email.from pw email.to")
|
||||
sys.exit(1)
|
||||
|
||||
host, fromaddr, pw, toaddr = sys.argv[1:5]
|
||||
msg = """From: %s
|
||||
To: %s
|
||||
Subject: SMTP server test
|
||||
|
||||
This is a test message.""" % (fromaddr, sys.argv[1])
|
||||
This is a test message.""" % (fromaddr, toaddr)
|
||||
|
||||
server = smtplib.SMTP(os.environ["INSTANCE_IP"], 587)
|
||||
server = smtplib.SMTP(host, 587)
|
||||
server.set_debuglevel(1)
|
||||
server.starttls()
|
||||
server.login(fromaddr, "testpw")
|
||||
server.sendmail(fromaddr, [sys.argv[1]], msg)
|
||||
server.login(fromaddr, pw)
|
||||
server.sendmail(fromaddr, [toaddr], msg)
|
||||
server.quit()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user