In this project, I developed a Thunderbird extension that uses ChatGPT for advanced spam detection. Incoming emails are automatically analyzed and classified according to various criteria. A local Flask server handles the communication with ChatGPT and assesses whether a message should be classified as spam. The implementation serves as a demo to explore the possibilities of AI-powered filtering in Thunderbird.

Workflow
As soon as Thunderbird receives a new email, the extension becomes active. The message is intercepted before it is viewed by the user. The extension extracts the subject, the sender, and the email body.
These data are sent to the local Flask server.
The Flask server forwards the request to ChatGPTweiter. The model analyzes the email based on predefined spam criteria (prompt). The AI decides: SPAM or NOT SPAM.
The OpenAI model’s response contains one of three possible decisions:
SPAM → email is moved
NOT SPAM → email remains in the inbox
UNSURE → no action (the user decides)
Extension

Configuration

Thunderbird Logging

Note: This code is implemented as a “quick and dirty” demo and is intended for demonstration purposes only.
Source code: Github
