Open dcfreire opened 1 year ago
Not right now, but it does look very similar to SMTP. Possible we could add it in future. If you want to try to get together a PR, that might speed things up 🙂
I'll work on it when I get some free time.
I tried implementing it similarly to how python's smtplib implements it, by extending the SMTP class and changing the EHLO command to LHLO, but it doesn't deliver the email and throws.
DEBUG:asyncio:Using selector: EpollSelector
DEBUG:asyncio:Get address info localhost:24, type=<SocketKind.SOCK_STREAM: 1>
DEBUG:asyncio:Getting address info localhost:24, type=<SocketKind.SOCK_STREAM: 1> took 1.631ms: [(<AddressFamily.AF_INET6: 10>, <SocketKind.SOCK_STREAM: 1>, 6, '', ('::1', 24, 0, 0)), (<AddressFamily.AF_INET: 2>, <SocketKind.SOCK_STREAM: 1>, 6, '', ('127.0.0.1', 24))]
DEBUG:asyncio:<asyncio.TransportSocket fd=6, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('127.0.0.1', 46574), raddr=('127.0.0.1', 24)> connected to localhost:24: (<_SelectorSocketTransport fd=6 read=polling write=<idle, bufsize=0>>, <aiosmtplib.protocol.SMTPProtocol object at 0x7fc8ab964550>)
DEBUG:asyncio:Close <_UnixSelectorEventLoop running=False closed=False debug=True>
ERROR:asyncio:Future exception was never retrieved
future: <Future finished exception=SMTPServerDisconnected('Connection lost') created at /usr/lib/python3.10/asyncio/base_events.py:429>
source_traceback: Object created at (most recent call last):
File "/home/shi/Documents/aiosmtplib/main.py", line 25, in <module>
asyncio.run(main())
File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/lib/python3.10/asyncio/base_events.py", line 636, in run_until_complete
self.run_forever()
File "/usr/lib/python3.10/asyncio/base_events.py", line 603, in run_forever
self._run_once()
File "/usr/lib/python3.10/asyncio/base_events.py", line 1901, in _run_once
handle._run()
File "/usr/lib/python3.10/asyncio/events.py", line 80, in _run
self._context.run(self._callback, *self._args)
File "/home/shi/Documents/aiosmtplib/main.py", line 18, in main
await a.send_message(message)
File "/home/shi/Documents/aiosmtplib/aiosmtplib/smtp.py", line 1424, in send_message
return await self.sendmail(
File "/home/shi/Documents/aiosmtplib/aiosmtplib/smtp.py", line 1301, in sendmail
response = await self.data(message, timeout=timeout)
File "/home/shi/Documents/aiosmtplib/aiosmtplib/smtp.py", line 894, in data
return await self.protocol.execute_data_command(message, timeout=timeout)
File "/home/shi/Documents/aiosmtplib/aiosmtplib/protocol.py", line 328, in execute_data_command
response = await self.read_response(timeout=timeout)
File "/home/shi/Documents/aiosmtplib/aiosmtplib/protocol.py", line 271, in read_response
self._response_waiter = self._loop.create_future()
File "/usr/lib/python3.10/asyncio/base_events.py", line 429, in create_future
return futures.Future(loop=self)
aiosmtplib.errors.SMTPServerDisconnected: Connection lost
I have no idea why this happens, from what I can tell all the commands are sent correctly, but when the server replies to the data command the client abruptly disconnects. Here is the conversation that produced the error above
Connection from 127.0.0.1:52560
S: 220 localhost LMTP server ready
C: LHLO daniel-computer S: S: 250-daniel-computer
S: 250-PIPELINING
S: 250 SIZE
C: MAIL FROM:<local@localhost> size=185
S: 250 OK
C: RCPT TO:<local@localhost>
S: 250 OK
C: DATA
S: 354 Start mail input; end with <CRLF>.<CRLF>
C: From: local@localhost
C: To: local@localhost
C: Subject: Hello World!
C: Content-Type: text/plain; charset="utf-8"
C: Content-Transfer-Encoding: 7bit
C: MIME-Version: 1.0
C:
C: Sent via aiosmtplib
C: .
S: 250 OK <--- disconnects here
Python's smtplib has a LMTP client for sending mails through the LMTP protocol. This is missing from aiosmtplib, are there plans for supporting sending emails through LMTP?