aiosmtpd - python smtp server

Viewed 3172

I'm trying to run my own stmp server on my computer with python and the aiosmtpd library.
I run the example, everything looks fine but I never receive the email on the other side.
I don't know if there are logs I can see.
I'm using visual studio 2015, python 3.5, and windows 8.1

I saw a similar post but it didn't help.

important note:
at the Client code, I also tried without the Date header

server.py:

 import asyncio import logging

 from aiosmtpd.controller import Controller
 from aiosmtpd.handlers import Sink
 from smtplib import SMTP

 async def amain(loop):
     cont = Controller(Sink(), hostname='::0', port=8025)
     cont.start()


 if __name__ == '__main__':
     logging.basicConfig(level=logging.DEBUG)
     loop = asyncio.get_event_loop()
     loop.create_task(amain(loop=loop))
     try:
         loop.run_forever()
     except KeyboardInterrupt:
         pass

Client.py:

 from smtplib import SMTP import smtplib

 s = SMTP('localhost', 8025) try:
     s.set_debuglevel(True)
     s.sendmail('andy@love.com', ['bob@hate.com'], """\
     Date:17/05/2017,2:18
     From: andy@love.com
     To: bob@hate.com
     Subject: A test
     testing
     """)
     s.quit() except smtplib.SMTPException:
     print("Error: unable to send email")
     import traceback
     traceback.print_exc()

Update
I set s.set_debuglevel(True) at Client.py and received this output:

send: 'ehlo [192.168.56.1]\r\n'
reply: b'250-mycomputername\r\n'
reply: b'250-SIZE 33554432\r\n'
reply: b'250-8BITMIME\r\n'
reply: b'250-SMTPUTF8\r\n'
reply: b'250 HELP\r\n'
reply: retcode (250); Msg: mycomputername\nSIZE 
33554432\n8BITMIME\nSMTPUTF8\nHELP'
send: 'mail FROM:<andy@love.com> size=122\r\n'
reply: b'250 OK\r\n'
reply: retcode (250); Msg: b'OK'
send: 'rcpt TO:<myreal@email.com>\r\n'
reply: b'250 OK\r\n'
reply: retcode (250); Msg: b'OK'
send: 'data\r\n'
reply: b'354 End data with <CR><LF>.<CR><LF>\r\n'
reply: retcode (354); Msg: b'End data with <CR><LF>.<CR><LF>'
data: (354, b'End data with <CR><LF>.<CR><LF>')
send: b'     Date:17/05/2017,2:18\r\n     From: andy@love.com\r\n     To: 
myreal@email.com\r\n     Subject: A test\r\n     testing\r\n     \r\n.\r\n'
reply: b'250 OK\r\n'
reply: retcode (250); Msg: b'OK'
data: (250, b'OK')
send: 'quit\r\n'
reply: b'221 Bye\r\n'
reply: retcode (221); Msg: b'Bye'
Press any key to continue . . .
1 Answers
Related