updated maildb state

This commit is contained in:
Paul 2024-01-27 10:42:03 +01:00
parent 03c24893d0
commit 914a774113

View File

@ -13,10 +13,10 @@ def DBConfig(configfile):
config.read(configfile)
d_dbconfig = {
'host' : config.get("maildb", "hostname"),
'user' : config.get("maildb", "username"),
'passwd' : config.get("maildb", "password"),
'db' : config.get("maildb", "database")
"host" : config.get("maildb", "hostname"),
"user" : config.get("maildb", "username"),
"passwd" : config.get("maildb", "password"),
"db" : config.get("maildb", "database")
}
return d_dbconfig
@ -35,14 +35,16 @@ def CloseDB(conn):
def CreateDB(conn, cursor):
try:
cursor.execute('''CREATE TABLE IF NOT EXISTS mail (
id serial NOT NULL,
sender text NULL,
recipient text NULL,
"date" timestamp NOT NULL DEFAULT NOW(),
"content" text NULL,
CONSTRAINT mail_pkey PRIMARY KEY (id)
)''')
cursor.execute('''
CREATE TABLE IF NOT EXISTS mail (
id serial NOT NULL,
sender text NULL,
recipient text NULL,
"date" timestamp NOT NULL DEFAULT NOW(),
"content" text NULL,
CONSTRAINT mail_pkey PRIMARY KEY (id)
)
''')
conn.commit()
except Exception as e:
print(e)
@ -64,8 +66,8 @@ def ParseMail(input_data):
content += line
msgobj = email.message_from_string(content)
sender = parseaddr(msgobj['From'])[1]
recipient = parseaddr(msgobj['To'])[1]
sender = parseaddr(msgobj["From"])[1]
recipient = parseaddr(msgobj["To"])[1]
return sender, recipient, content
@ -92,5 +94,5 @@ def main():
CloseDB(conn)
if __name__ == '__main__':
if __name__ == "__main__":
main()