-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.py
More file actions
34 lines (25 loc) · 1.07 KB
/
server.py
File metadata and controls
34 lines (25 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import smtpd
import asyncore
from dbconn import accessDB
#from dbconn import closeDB
from crypto_secure import AESCipher
class CustomSMTPServer(smtpd.SMTPServer):
def process_message(self, peer, mailfrom, rcpttos, data):
print 'Receiving message from:', peer
print 'Message addressed from:', mailfrom
print 'Message addressed to :', rcpttos
print 'Message length :', len(data)
print '---------------------'
#all methods below are for DB insertion
mail_to=''.join(rcpttos) #rcpttos is list, converted to string here
#print 'STRING: ', recieptto
mail_from=mailfrom
mail_data=data
cipherobj=AESCipher('thisisthekey')
cipher_text=cipherobj.encrypt(mail_data)
print 'Original mail data is:',data
print 'Encrypted is\n',cipher_text
accessDB(mail_to,mail_from,cipher_text)
server = CustomSMTPServer(('192.168.137.128', 1025), None)
print 'SMTP server running...'
asyncore.loop()