bamthomas / aioimaplib

Python asyncio IMAP4rev1 client library
GNU General Public License v3.0
135 stars 58 forks source link

APPEND doesn't working #24

Closed dant4z closed 7 years ago

dant4z commented 7 years ago

Hi, i have some troubles with APPEND command. It receives message that server ready to receive literal data and do nothing. This is part of asyncio debug log:

DEBUG:aioimaplib.aioimaplib:Sending : b'LION1 LOGIN xxx "xxx"\r\n'
DEBUG:asyncio:poll 59997.714 ms took 57.081 ms: 1 events
DEBUG:aioimaplib.aioimaplib:Received : b'* CAPABILITY IMAP4rev1 CHILDREN UNSELECT LITERAL+ NAMESPACE XLIST BINARY UIDPLUS ENABLE ID IDLE MOVE\r\nLION1 OK LOGIN Completed.\r\n'
DEBUG:aioimaplib.aioimaplib:tagged status LION1 OK LOGIN Completed.
DEBUG:aioimaplib.aioimaplib:state -> AUTH
DEBUG:aioimaplib.aioimaplib:Sending : b'LION2 APPEND INBOX {17602}\r\n'
DEBUG:asyncio:poll 59998.721 ms took 9.665 ms: 1 events
DEBUG:aioimaplib.aioimaplib:Received : b'+ go ahead with 17602 octets\r\n'
DEBUG:aioimaplib.aioimaplib:continuation line appended to pending sync command LION2 APPEND INBOX {17602} : + go ahead with 17602 octets
INFO:asyncio:poll 59987.636 ms took 59991.798 ms: timeout
bamthomas commented 7 years ago

This is weird, it is tested. Could you show how you used the imaplib append method ?

dant4z commented 7 years ago
import asyncio
from aioimaplib import aioimaplib
import email.message
import logging
logging.basicConfig(level=logging.DEBUG)

addr = 'imap.gmail.com'
login = 'xxx@gmail.com'
password = 'xxx'

async def test():
    imap = aioimaplib.IMAP4_SSL(addr, 993, timeout=60)
    await imap.wait_hello_from_server()
    await imap.login(login, password)
    msg = email.message.EmailMessage()
    msg.set_unixfrom('pymotw')
    msg['From'] = login
    msg['To'] = login
    msg.set_content(b'test', 'text', 'plain')
    await imap.append(bytes(msg))

loop = asyncio.get_event_loop()
loop.run_until_complete(test())

Log:

DEBUG:aioimaplib.aioimaplib:state -> AUTH
DEBUG:aioimaplib.aioimaplib:Sending : b'DOBN2 APPEND INBOX {143}\r\n'
DEBUG:asyncio:poll 59998.067 ms took 20.075 ms: 1 events
DEBUG:aioimaplib.aioimaplib:Received : b'+ go ahead\r\n'
DEBUG:aioimaplib.aioimaplib:continuation line appended to pending sync command DOBN2 APPEND INBOX {143} : + go ahead
INFO:asyncio:poll 59977.141 ms took 59977.208 ms: timeout

What i'm doing wrong?

bamthomas commented 7 years ago

I'm trying to reproduce, it seems that the mail data is never sent.

bamthomas commented 7 years ago

We are waiting 'literal data' in the server continuation line and it sends 'go ahead'.

Thank you for your bug report.

I'm fixing this.

bamthomas commented 7 years ago

Could you tell me if the commit fae66fd fixes your issue ? (it should) I released a 0.7.12 version that should fix this. I close the issue, you can reopen it if it does not work

dant4z commented 7 years ago

Yes, now it works, thanks!