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

SSL wrong version number #12

Closed
TheZoker opened this issue Mar 14, 2024 · 5 comments
Closed

SSL wrong version number #12

TheZoker opened this issue Mar 14, 2024 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@TheZoker
Copy link

When I try to archive my mail, I get this error:

2024-03-14 14:42:38,964 - ERROR - Exception details: Traceback (most recent call last):
  File "/app/email_archiver.py", line 103, in fetch_and_archive_emails
    client = imaplib.IMAP4_SSL(server, port)
  File "/usr/local/lib/python3.9/imaplib.py", line 1324, in __init__
    IMAP4.__init__(self, host, port, timeout)
  File "/usr/local/lib/python3.9/imaplib.py", line 202, in __init__
    self.open(host, port, timeout)
  File "/usr/local/lib/python3.9/imaplib.py", line 1337, in open
    IMAP4.open(self, host, port, timeout)
  File "/usr/local/lib/python3.9/imaplib.py", line 312, in open
    self.sock = self._create_socket(timeout)
  File "/usr/local/lib/python3.9/imaplib.py", line 1328, in _create_socket
    return self.ssl_context.wrap_socket(sock,
  File "/usr/local/lib/python3.9/ssl.py", line 501, in wrap_socket
    return self.sslsocket_class._create(
  File "/usr/local/lib/python3.9/ssl.py", line 1074, in _create
    self.do_handshake()
  File "/usr/local/lib/python3.9/ssl.py", line 1343, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLError: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1129)

I use IMAP with the port 143.

These are the ports provided by my hoster:

image

Which combination should I use to get this working? Thanks!

@bandundu
Copy link
Owner

bandundu commented Mar 14, 2024

For now, the application does not support unsecured connections. This is something I will add. For IMAP or POP3 with SSL/TLS should work.

@TheZoker
Copy link
Author

TheZoker commented Mar 14, 2024

Alright, thanks for the clarification.

I now tried IMAP with 993.

I now get this error:

2024-03-14 14:58:52,630 - ERROR - An error occurred during email archiving for account 1: expected string or bytes-like object
2024-03-14 14:58:52,631 - ERROR - Exception details: Traceback (most recent call last):
  File "/app/email_archiver.py", line 160, in fetch_and_archive_emails
    recipients_parts = email.header.decode_header(email_message['To'])
  File "/usr/local/lib/python3.9/email/header.py", line 80, in decode_header
    if not ecre.search(header):
TypeError: expected string or bytes-like object

And the script stops.

I have a lot of these lines in the logs:

2024-03-14 14:58:52,470 - INFO - Inserted email with UID b'18864' for account 1 into the database.
2024-03-14 14:58:52,505 - INFO - Inserted email with UID b'18865' for account 1 into the database.
2024-03-14 14:58:52,540 - INFO - Inserted email with UID b'18866' for account 1 into the database.
2024-03-14 14:58:52,559 - INFO - Inserted email with UID b'18868' for account 1 into the database.
2024-03-14 14:58:52,594 - INFO - Inserted email with UID b'18870' for account 1 into the database.
2024-03-14 14:58:52,613 - INFO - Inserted email with UID b'18874' for account 1 into the database.

But the dashboard still shows 0 archived emails:
image

Edit:
In between I also get this error:

2024-03-14 14:58:45,507 - ERROR - Exception details: Traceback (most recent call last):
  File "/app/email_archiver.py", line 207, in fetch_and_archive_emails
    cursor.execute('''INSERT INTO emails (account_id, subject, sender, recipients, date, body, unique_id)
sqlite3.OperationalError: database is locked

Edit2:
I found out, that it's about this email, which has no [To] info:
image

Maybe just skip this message and log an error in the dashboard or something? Still strange, that the other emails are missing in the dashboard

@bandundu bandundu added the bug Something isn't working label Mar 16, 2024
@bandundu bandundu self-assigned this Mar 16, 2024
@bandundu
Copy link
Owner

Really interesting. Out of curiosity, how would you get emails without TO header? Did not expect this.

Should be fixed in latest release, please retry and give me feedback

@bandundu bandundu mentioned this issue Mar 16, 2024
@TheZoker
Copy link
Author

I think that can happen when you use BCC without TO.

Looks good, I think this issue is fixed.

I now have this error:

2024-03-18 07:19:30,763 - ERROR - Exception details: Traceback (most recent call last):
  File "/app/email_archiver.py", line 155, in fetch_and_archive_emails
    decoded_sender_parts.append(part.decode(encoding or 'utf-8'))
LookupError: unknown encoding: unknown-8bit

I wonder why no mail has been archived yet. Is the operation only successful, if there is no error during the process? Because the logs show a lot of

2024-03-18 07:24:32,563 - INFO - Inserted email with UID b'18705' for account 1 into the database.

but still nothing in the dashboard.

@bandundu
Copy link
Owner

bandundu commented Mar 18, 2024

@TheZoker created a seperate issue #14 as the initial bug of this one seems to be solved.

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

2 participants