New option to review mail to be send

This commit is contained in:
nemunaire 2017-10-26 00:22:11 +02:00
parent f3ea2af897
commit 4d9ac08a89

View File

@ -12,6 +12,7 @@ SOFT_MAX_SUBMISSION = None
HARD_MAX_SUBMISSION = None HARD_MAX_SUBMISSION = None
FROM = "Automatic VIRLI Mail Checker <virli@nemunai.re>" FROM = "Automatic VIRLI Mail Checker <virli@nemunai.re>"
SEND_TO_REALUSER = False SEND_TO_REALUSER = False
REVIEW_BEFORE_SEND = False
BETA = False BETA = False
ALTERNATE_RESOLUTIONS = False ALTERNATE_RESOLUTIONS = False
@ -107,11 +108,17 @@ running for nemunaire@nemunai.re""")
import smtplib import smtplib
with smtplib.SMTP("localhost") as smtp: with smtplib.SMTP("localhost") as smtp:
smtp.starttls() smtp.starttls()
if not SEND_TO_REALUSER or REVIEW_BEFORE_SEND:
print(msg.as_string())
if REVIEW_BEFORE_SEND:
import time
for i in range(15):
sys.stdout.write(".")
sys.stdout.flush()
time.sleep(1)
if SEND_TO_REALUSER: if SEND_TO_REALUSER:
smtp.send_message(msg) smtp.send_message(msg)
smtp.send_message(msg, to_addrs=["virli-report@nemunai.re"]) smtp.send_message(msg, to_addrs=["virli-report@nemunai.re"])
else:
print(msg.as_string())
def readmail(fp): def readmail(fp):
@ -214,6 +221,9 @@ if __name__ == '__main__':
parser.add_argument('--expected-submission-hash', parser.add_argument('--expected-submission-hash',
help="imposed tarball hash") help="imposed tarball hash")
parser.add_argument('--review-before-send', action="store_true",
help="Review the e-mail to be sent before sending it")
parser.add_argument('--beta', action="store_true", parser.add_argument('--beta', action="store_true",
help="enable beta features") help="enable beta features")
@ -231,6 +241,7 @@ if __name__ == '__main__':
ALTERNATE_RESOLUTIONS = args.alternate_resolutions ALTERNATE_RESOLUTIONS = args.alternate_resolutions
SEND_TO_REALUSER = args.real_send SEND_TO_REALUSER = args.real_send
REVIEW_BEFORE_SEND = args.review_before_send
BETA = args.beta BETA = args.beta
cnt, frm, subject, ref = readmail(sys.stdin.buffer) cnt, frm, subject, ref = readmail(sys.stdin.buffer)