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