|
|
@ -23,6 +23,7 @@ poll "{host}" proto {protocol} port {port}
|
|
|
|
sslproto 'AUTO'
|
|
|
|
sslproto 'AUTO'
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def escape_rc_string(arg):
|
|
|
|
def escape_rc_string(arg):
|
|
|
|
return arg.replace("\\", "\\\\").replace('"', '\\"')
|
|
|
|
return arg.replace("\\", "\\\\").replace('"', '\\"')
|
|
|
|
|
|
|
|
|
|
|
@ -57,21 +58,21 @@ def run(connection, cursor, keep, debug):
|
|
|
|
options=options
|
|
|
|
options=options
|
|
|
|
)
|
|
|
|
)
|
|
|
|
if debug:
|
|
|
|
if debug:
|
|
|
|
print( fetchmailrc )
|
|
|
|
print(fetchmailrc)
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
print( fetchmail( fetchmailrc ) )
|
|
|
|
print(fetchmail(fetchmailrc))
|
|
|
|
error_message = ""
|
|
|
|
error_message = ""
|
|
|
|
except subprocess.CalledProcessError as error:
|
|
|
|
except subprocess.CalledProcessError as error:
|
|
|
|
error_message = error.output.decode( "utf8" )
|
|
|
|
error_message = error.output.decode("utf8")
|
|
|
|
# No mail is not an error
|
|
|
|
# No mail is not an error
|
|
|
|
if not error_message.startswith("fetchmail: No mail"):
|
|
|
|
if not error_message.startswith("fetchmail: No mail"):
|
|
|
|
print( error_message )
|
|
|
|
print(error_message)
|
|
|
|
|
|
|
|
user_info = "for %s at %s" % (user_email, host)
|
|
|
|
user_info = "for %s at %s" % ( user_email, host )
|
|
|
|
|
|
|
|
# Number of messages seen is not a error as well
|
|
|
|
# Number of messages seen is not a error as well
|
|
|
|
if "messages" in error_message and "(seen " in error_message and \
|
|
|
|
if ("messages" in error_message and
|
|
|
|
user_info in error_message:
|
|
|
|
"(seen " in error_message and
|
|
|
|
print( error_message )
|
|
|
|
user_info in error_message):
|
|
|
|
|
|
|
|
print(error_message)
|
|
|
|
finally:
|
|
|
|
finally:
|
|
|
|
cursor.execute("""
|
|
|
|
cursor.execute("""
|
|
|
|
UPDATE fetch SET error=?, last_check=datetime('now')
|
|
|
|
UPDATE fetch SET error=?, last_check=datetime('now')
|
|
|
@ -80,7 +81,6 @@ def run(connection, cursor, keep, debug):
|
|
|
|
connection.commit()
|
|
|
|
connection.commit()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
if __name__ == "__main__":
|
|
|
|
debug = os.environ.get("DEBUG", None) == "True"
|
|
|
|
debug = os.environ.get("DEBUG", None) == "True"
|
|
|
|
keep = os.environ.get("FETCHMAIL_KEEP", None) == "True"
|
|
|
|
keep = os.environ.get("FETCHMAIL_KEEP", None) == "True"
|
|
|
@ -91,4 +91,3 @@ if __name__ == "__main__":
|
|
|
|
run(connection, cursor, keep, debug)
|
|
|
|
run(connection, cursor, keep, debug)
|
|
|
|
cursor.close()
|
|
|
|
cursor.close()
|
|
|
|
time.sleep(int(os.environ.get("FETCHMAIL_DELAY", 60)))
|
|
|
|
time.sleep(int(os.environ.get("FETCHMAIL_DELAY", 60)))
|
|
|
|
|
|
|
|
|
|
|
|