The ScnMsg email client is a simple email client created using Python and some HTML with an aim to detect, reduce, and hopefully prevent malware execution, scams, and phishing attempts on the technology illiterate, cyber-unaware, and especially the elderly population that can be easily manipulated. The goal is to integrate features that will check emails against existing tools, such as Virus Total, and use AI to assess contents to provide a scoring mechanism to alert a user to potential risks through use of Groq API calls. Complex features seen in other email clients such as automatic replies, folder sorting, and advanced filtering rules will intentionally be left out since the target users for this software would likely not be the group to leverage those features and may make its use more complicated for the anticipated user.
This is a high level summary covering the order of operations for the application. Please see the Screenshots and Code Explanation for a lower level description of functionality:
- Download emails from the email provider IMAP server
- Scan email contents and attached files
- Generate a report based on the returned scan and analysis results
- Launch and open the GUI
- User interacts with the application, can view and reply to emails, and open email reports in the browser
The ScnMsg icon was created using ChatGPT, with the prompt:
Can you make an icon for an application I'm building called ScnMsg?
This proposal is to make a simple email client using Python to detect, reduce, and hopefully prevent malware execution, scams, and phishing attempts on the technology illiterate, cyber-unaware, and especially the elderly population that can be easily manipulated. The goal is to integrate features that will check emails against existing tools and use AI to assess contents to provide a scoring mechanism to alert a user to potential risks.
AI was also used to create phishing email that was sent to see if Llama would indicate the message as likely a phishing attempt, as well as some other files that were sent from another test email to see if messages that were inteded as cybersecurity notices would be falsely marked as SPAM.
Finally, AI is being actively used within the code using Groq API calls in order to categorize the emails as Normal, Spam, Phishing, etc. based on the contents of the email body.
-
Install Python on your system:
Windows: Navigate to https://www.python.org/downloads/ and install the latest version of Python 3 using your GUI
Linux:sudo apt install python3 -
The following are not standard Python3 libraries and must be installed manually before use:
- bs4 (BeautifulSoup)
- imap_tools
- jinja2
- PyQt5
- requests
- vt (Virus Total)
Use this command to install these packages before attempting to run the code:
pip install beautifulsoup4 imap-tools Jinja2 PyQt5 requests virustotal-python
Note: May need to add pip to your systems PATH (environment variables).
- To run the application GUI, run either of these commands from the root folder (ScnMsg) of the code:
Windows:python .\Python\email_client.py
Linux:python3 .\Python\email_client.py
Notes: Command syntax may vary by OS or other settings. MacOS has not been tested for this project.
| Module or Package | Component(s) | Usage |
|---|---|---|
| bs4 | BeautifulSoup | Used to convert an HTML only email to text due to Groq API token restrictions. |
| configparser | - | Use of Config file for storing email settings |
| hashlib | - | Hashing of files for faster VirusTotal lookup |
| imap_tools | MailBox | Recieve emails from an email provider using IMAP server |
| io | BytesIO | Convert attachments to bytes for VirusTotal scanning of files |
| jinja2 | - | Template engine that builds HTML report files with passed variables |
| json | - | Read returned Gorq data as JSON format |
| operator | itemgetter | Sort emails from newest to oldest, or vice versa |
| os | - | USE CASE |
| pickle | - | Save each email in its own pickle file to avoid filling RAM |
| PyQt5 | QtGui QtWidgets |
Email Client GUI |
| requests | - | Integration with Groq API via URL POST request |
| sys | - | Start and Exit the Application GUI |
| time | - | Pause between VirusTotal API calls when using Public API key |
| vt | - | Integration with VirusTotal API |
| webbrowser | - | Open the email reports in a webbrowser |
This section displays tables containing screenshots of key secitons of code code with descriptions of the functionality being performed for each package (file) of the program.
This Python module is reponsible for creating, loading, and running the application in a GUI.
This Python module is reponsible for downloading emails from the IMAP server set in the settings menu, saving each email to a pickle file, and creating a list of dictionaries that represent summary data for all emails. It has an additional function that can be called by other modules to load a single pickle file and return the needed contents from the object.
This Python module is reponsible for analyzing the email contents and attachments to create the data for the email scan report.
This Python module is reponsible for creating the reports for each email by filling in an HTML template form.
This HTML template is the foundation for every email scan report
The following areas for future improvement of expansion of this software have been identified
- Implement sending of emails (SMTP integration)
- Implement deletion of emails
- Implement "Mark as SPAM" fature, and integrate scoring into category analysis
- Header analysis (sender obfuscation, extraction of other data to analyze: domains, IPs, etc.)
- Link analysis (URL Scan)
- Short link analysis (short link expansion for transparency)
- IP analysis (WHOIS, geolocation)
- Refinement of AI system prompt to better detect SPAM emails
- Refinement of AI system prompt to in include additonal categories (personal, work, etc.)
- Cleanup code (effciency / clarity)
- Implement robust commenting for complex code
- Alternative scanners to VirusTotal (in liu of Private API key, faster scanning)





















