awalon / MailToTelegramForwarder

MailToTelegramForwarder is a Python based daemon that will fetch mails from a remote IMAP server and forward them via Telegram API.
GNU General Public License v3.0
40 stars 19 forks source link

Error occurred [loop]: UID command error: BAD [b'Command Argument Error. 11'] #9

Open tknikita opened 2 years ago

tknikita commented 2 years ago

hello!

i got the following error when connect to Exchange OWA mailbox via IMAP

<2> Mail to Telegram Forwarder: Error occurred [loop]: UID command error: BAD [b'Command Argument Error. 11']. Data: b'EBCB6 UID SEARCH UID *\r\n' [/opt/rr-rps-mail-to-telegram-forwarder/mailToTelegramForwarder.py:1051 in 'main']
arubia45 commented 2 years ago

Hello, I have the same problem with both the mail of yahoo.es/mailfence.com

Greetings.

arubia45 commented 2 years ago

Google Mail:

<2> Mail to Telegram Forwarder: Error occurred [loop]: UID command error: BAD [b'Could not parse command']. Data: b'HCDI6 UID SEARCH UID *\r\n'
lacrimal commented 2 years ago

Google mail is not 100% imap compliant, from 0.1.2 version of forwarder I'm using modification. It will resend email from specified folder when it is marked as unread, so you can use specific filter like: search: (UID ${lastUID}:* UNSEEN HEADER FROM "specific@email.com") my changes:

739c739,740
<         rv, data = self.mailbox.uid('search', '', 'UID *')
---
>         rv, data = self.mailbox.select(self.config.imap_folder)
>         rv, data = self.mailbox.uid('SEARCH', None, 'UNSEEN')
905c906,907
<             rv, data = self.mailbox.uid('search', '', search_string)
---
>             rv, data = self.mailbox.select(self.config.imap_folder)
>             rv, data = self.mailbox.uid('search', None, search_string)
942a945
>                 rv, data = self.mailbox.select(self.config.imap_folder)
arubia45 commented 2 years ago

Good morning, I have made the modifications but I get the same error. I don't know if I've done them right, if you can leave me your file mailToTelegramForwarder.py complete with the modifications I would appreciate it.

Mail to Telegram Forwarder: Error occurred [loop]: UID command error: BAD [b'Could not parse command']. Data: b'KCIE6 UID SEARCH UID *\r\n'

Thank you

lacrimal commented 2 years ago

Here you go: downloads.zip ./m2t --config m2t.conf

Also replace <...> tags in my m2t2.conf if you use one to suffice your needs.

Needed to install python 3.9 to get whole script to work so lookup at top interpreter declaration.

arubia45 commented 2 years ago

Thanks

arubia45 commented 2 years ago

Hello, with what you sent me it works for me although it only works when there is an unread email if there is more than one does not forward them to Telegram It happens to you too? Thank you

lacrimal commented 2 years ago

you are right - never received more than one message in one loop so never tested this issue

lacrimal commented 2 years ago

Problem was when +1 messages appear, whole array was shown as UID - that was obvious error. Now

You can filter interesting emails by tag (folder) and additionally by any other option that IMAP query supports (look at my previous post about UNSEEN HEADER FROM). Below is working one: mailToTelegramForwarder.zip

martin1551 commented 1 year ago

definitely @lacrimal patch fixes the issue. It would be cool to merge it into awalon:master as well.