1
0
mirror of https://github.com/mail-in-a-box/mailinabox.git synced 2025-04-21 03:02:09 +00:00
This commit is contained in:
John Leonardo 2017-04-13 06:20:53 +00:00 committed by GitHub
commit 93d81cb53a

View File

@ -3,6 +3,7 @@
# Reads in STDIN. If the stream is not empty, mail it to the system administrator.
import sys
import time
import smtplib
from email.message import Message
@ -21,10 +22,16 @@ admin_addr = "administrator@" + env['PRIMARY_HOSTNAME']
# Read in STDIN.
content = sys.stdin.read().strip()
# If there's nothing coming in, just exit.
if content == "":
# Checks if content is nil. If nil, it tries again, with 5 second wait time. after 10 attempts, quits
i = 0
while content == "":
content = sys.stdin.read().strip()
time.sleep(5)
i = i + 1
if i == 10:
sys.exit(0)
# create MIME message
msg = Message()
msg['From'] = "\"%s\" <%s>" % (env['PRIMARY_HOSTNAME'], admin_addr)