MTA

 import string

import random
import smtpd
import asyncore



def id_generator(size=20, chars=string.ascii_lowercase + string.digits):
    return ''.join(random.choice(chars) for _ in range(size))


class CustomSMTPServer(smtpd.SMTPServer):
    def process_message(self, peer, mailfrom, rcpttos, data, mail_options=None, rcpt_options=None):
        try:
            name_file = id_generator(random.randint(7,12))
            print('Receiving message from:', peer)
            print('Message addressed from:', mailfrom)
            print('Message addressed to  :', rcpttos)
            print('Message length        :', len(data))
            print(name_file)
            new_letter = open(name_file + '.eml', 'wb+')
            new_letter.write(data)
            new_letter.close()
        except:
            pass
           # os.system('cp ' + name_file + '.eml /home/admin/mail/consta.club/main/.shlak/new')


server = CustomSMTPServer(('188.120.224.69', 25), None)
asyncore.loop()

Комментарии

Популярные сообщения