Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

imap2gg uses port 993 instead of 143 #5

Closed
rzmunch opened this issue Jan 22, 2021 · 6 comments
Closed

imap2gg uses port 993 instead of 143 #5

rzmunch opened this issue Jan 22, 2021 · 6 comments
Labels
bug Something isn't working

Comments

@rzmunch
Copy link

rzmunch commented Jan 22, 2021

When I try to use it with my mailserver, I get this error:

Error while interacting with the IMAP SERVER: '[WinError 10061] No connection could be made because the target machine actively refused it'

Sniffing my packets, it uses IMAPS in the port 993, but I only have the port 143 (not encrypted).

I did try to use ip:port but it doesn't work ( '[Errno 11001] getaddrinfo failed' )

Thanks for your help.

@rzmunch
Copy link
Author

rzmunch commented Jan 22, 2021

I found MailBoxUnencrypetd in imap_tools imported modified the script and got a different error:

Error while interacting with the IMAP SERVER: ''MailBoxUnencrypted' object has no attribute '_criteria_encoder''

@rzmunch
Copy link
Author

rzmunch commented Jan 23, 2021

I found MailBoxUnencrypetd in imap_tools imported modified the script and got a different error:

Error while interacting with the IMAP SERVER: ''MailBoxUnencrypted' object has no attribute '_criteria_encoder''

I found a workaround: put count = 1 and it worked.

So:

from imap_tools import MailBox
with MailBoxUnencrypted(self.server).login(
in def process --> count = 1 #self.count_elements(remote_mailbox)

Now to find a way to make it create labels for each folder. Thanks for the script.

@XaviTorello
Copy link
Owner

Great, ty for posting this workaround 👍

@XaviTorello XaviTorello added the bug Something isn't working label Jan 23, 2021
@Braintelligence
Copy link

Braintelligence commented Feb 8, 2021

@rzmunch Hey, did you find a way to create labels for each folder? :)

EDIT: Actually I have the exact same issue @XaviTorello - do you have an idea how I could tell it to use a different port?

EDIT2: Actually no, I have the issue about Error while interacting with the IMAP SERVER: ''MailBoxUnencrypted' object has no attribute '_criteria_encoder'' but the port is correct.

@Braintelligence
Copy link

Braintelligence commented Feb 9, 2021

I altered count = 1 as well, so it would actually start again.

Then I changed the ImapImporter process like this:

def process(self):
        """
        Try to connect to the IMAP server, and try process all matched emails
        """
        try:
            with MailBox(self.server).login(
                self.email, self.password
            ) as remote_mailbox:
                for folder in remote_mailbox.folder.list():
                    print(folder["name"])
                    remote_mailbox.folder.set(folder["name"])

                    count = 1 #self.count_elements(remote_mailbox)
                    if (count == 0):
                        print(
                            "There are'nt emails to be processed",
                            f"with query '{self.query}'"
                        )
                        return

                    for an_email in tqdm(
                        remote_mailbox.fetch(self.query),
                        total=count,
                        desc='Processing emails'
                    ):

                        try:
                            prep_str = an_email.obj.as_string()
                            esubindex = prep_str.find("Subject:")
                            esub = prep_str[esubindex-1:esubindex+20]
                            new_str = prep_str[:esubindex+8] + " [" + folder["name"] + "] " + prep_str[esubindex+8:]
                            an_email_str = new_str.encode('utf-8')
                            self.push_to_group(an_email_str)
                        except Exception as e:
                            self.handle_error(e, an_email.uid, an_email_str)

                self.show_errors()

        except Exception as e:
            print(f"Error while interacting with the IMAP SERVER: '{e}'")

This way all IMAP folders are iterated on and the IMAP folder name is prefixed to the Subject of the mail before uploading it.

Sadly there seems to be no way to set a label with the google groups migration API.

@sdepablos
Copy link

Another one with the same _criteria_encoder error. In my case in the Mailbox: Error while interacting with the IMAP SERVER: ''MailBox' object has no attribute '_criteria_encoder', and the count=1 in the imap library also solved the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants