tests: also test client submission over smtps://
instead of just smtp:// with STARTTLS. Opted to call the flag --ssl and not --tls to keep it consistent with the module option (mailserver.enableSubmissionSsl), dovecot internals and smtplib in mail-check.py.
This commit is contained in:
parent
958c112fba
commit
63b8e1615f
4 changed files with 33 additions and 21 deletions
|
@ -12,7 +12,15 @@ RETRY = 100
|
|||
|
||||
|
||||
def _send_mail(
|
||||
smtp_host, smtp_port, smtp_username, from_addr, from_pwd, to_addr, subject, starttls
|
||||
smtp_host,
|
||||
smtp_port,
|
||||
smtp_username,
|
||||
from_addr,
|
||||
from_pwd,
|
||||
to_addr,
|
||||
subject,
|
||||
starttls,
|
||||
ssl,
|
||||
):
|
||||
print(f"Sending mail with subject '{subject}'")
|
||||
message = "\n".join(
|
||||
|
@ -28,9 +36,10 @@ def _send_mail(
|
|||
)
|
||||
|
||||
retry = RETRY
|
||||
smtp_class = smtplib.SMTP_SSL if ssl else smtplib.SMTP
|
||||
while True:
|
||||
try:
|
||||
with smtplib.SMTP(smtp_host, port=smtp_port) as smtp:
|
||||
with smtp_class(smtp_host, port=smtp_port) as smtp:
|
||||
try:
|
||||
if starttls:
|
||||
smtp.starttls()
|
||||
|
@ -171,6 +180,7 @@ def send_and_read(args):
|
|||
to_addr=args.to_addr,
|
||||
subject=subject,
|
||||
starttls=args.smtp_starttls,
|
||||
ssl=args.smtp_ssl,
|
||||
)
|
||||
|
||||
_read_mail(
|
||||
|
@ -206,6 +216,7 @@ parser_send_and_read = subparsers.add_parser(
|
|||
parser_send_and_read.add_argument("--smtp-host", type=str)
|
||||
parser_send_and_read.add_argument("--smtp-port", type=str, default=25)
|
||||
parser_send_and_read.add_argument("--smtp-starttls", action="store_true")
|
||||
parser_send_and_read.add_argument("--smtp-ssl", action="store_true")
|
||||
parser_send_and_read.add_argument(
|
||||
"--smtp-username",
|
||||
type=str,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue