[GH-ISSUE #98] Recieving a NoneType error when sending a mail to its server when no subject #70

Closed
opened 2026-02-25 23:39:46 +03:00 by kerem · 0 comments
Owner

Originally created by @tanja84dk on GitHub (Mar 5, 2025).
Original GitHub issue: https://github.com/HaschekSolutions/opentrashmail/issues/98

I tried to setup the docker container within my home network and have set up the A, AAAA and MX records
But when ever I try to send mails to it ( wether its Thunderbird or smtpmail or even telnet directly ), i'm then always ending with that NoneType error

It looks like it fails completely is a message doesn't have a subject which I feel should be valid

It's setup here at first with pure plaintext and port 25

This is when I try to telnet directly in to the server and send the mail directly to it

tanja@ubuntu:~$ telnet 192.168.83.12 25
Trying 192.168.83.12...
Connected to 192.168.83.12.
Escape character is '^]'.
220 labmail.home.tanja84.dk Python SMTP 1.4.6
HELO labclient.home.tanja84.dk
250 labmail.home.tanja84.dk
mail from: client@labclient.home.tanja84.dk
250 OK
rcpt to: admin@labserver.home.tanja84.dk
250 OK
data
354 End data with <CR><LF>.<CR><LF>
This is a small test mail
Hope this works this time

.
500 Error: (TypeError) expected string or bytes-like object, got 'NoneType'```

And this is the traceback from within the servers container

2025-03-05 03:28:16,992 - __main__ - DEBUG - Receiving message from: ('192.168.88.5', 58872) (Plaintext)
2025-03-05 03:28:16,994 - __main__ - DEBUG - Message addressed from: client@labclient.home.tanja84.dk
2025-03-05 03:28:16,994 - __main__ - DEBUG - Message addressed to: ['admin@labserver.home.tanja84.dk']
('192.168.88.5', 58872) SMTP session exception
Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/aiosmtpd/smtp.py", line 756, in _handle_client
    await method(arg)
  File "/usr/lib/python3.11/site-packages/aiosmtpd/smtp.py", line 1519, in smtp_DATA
    status = await self._call_handler_hook('DATA')
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/aiosmtpd/smtp.py", line 473, in _call_handler_hook
    status = await hook(self, self.session, self.envelope, *args)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/var/www/opentrashmail/python/mailserver3.py", line 56, in handle_DATA
    subject = str(make_header(decode_header(message['subject'])))
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/email/header.py", line 78, in decode_header
    if not ecre.search(header):
           ^^^^^^^^^^^^^^^^^^^
TypeError: expected string or bytes-like object, got 'NoneType'

Originally created by @tanja84dk on GitHub (Mar 5, 2025). Original GitHub issue: https://github.com/HaschekSolutions/opentrashmail/issues/98 I tried to setup the docker container within my home network and have set up the A, AAAA and MX records But when ever I try to send mails to it ( wether its Thunderbird or smtpmail or even telnet directly ), i'm then always ending with that NoneType error It looks like it fails completely is a message doesn't have a subject which I feel should be valid It's setup here at first with pure plaintext and port 25 This is when I try to telnet directly in to the server and send the mail directly to it ``` tanja@ubuntu:~$ telnet 192.168.83.12 25 Trying 192.168.83.12... Connected to 192.168.83.12. Escape character is '^]'. 220 labmail.home.tanja84.dk Python SMTP 1.4.6 HELO labclient.home.tanja84.dk 250 labmail.home.tanja84.dk mail from: client@labclient.home.tanja84.dk 250 OK rcpt to: admin@labserver.home.tanja84.dk 250 OK data 354 End data with <CR><LF>.<CR><LF> This is a small test mail Hope this works this time . 500 Error: (TypeError) expected string or bytes-like object, got 'NoneType'``` ``` And this is the traceback from within the servers container ``` 2025-03-05 03:28:16,992 - __main__ - DEBUG - Receiving message from: ('192.168.88.5', 58872) (Plaintext) 2025-03-05 03:28:16,994 - __main__ - DEBUG - Message addressed from: client@labclient.home.tanja84.dk 2025-03-05 03:28:16,994 - __main__ - DEBUG - Message addressed to: ['admin@labserver.home.tanja84.dk'] ('192.168.88.5', 58872) SMTP session exception Traceback (most recent call last): File "/usr/lib/python3.11/site-packages/aiosmtpd/smtp.py", line 756, in _handle_client await method(arg) File "/usr/lib/python3.11/site-packages/aiosmtpd/smtp.py", line 1519, in smtp_DATA status = await self._call_handler_hook('DATA') ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/site-packages/aiosmtpd/smtp.py", line 473, in _call_handler_hook status = await hook(self, self.session, self.envelope, *args) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/var/www/opentrashmail/python/mailserver3.py", line 56, in handle_DATA subject = str(make_header(decode_header(message['subject']))) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/email/header.py", line 78, in decode_header if not ecre.search(header): ^^^^^^^^^^^^^^^^^^^ TypeError: expected string or bytes-like object, got 'NoneType' ```
kerem closed this issue 2026-02-25 23:39:46 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/opentrashmail#70
No description provided.