I'm new to python, and I want to create a program that can determine whether an email is a spam or not based on three factors.
The subject (if it's empty, it's spam), the sender (I only want people whose email addresses end with '.com,' for example, otherwise it's spam), and the date (I only want emails on non-weekend days, otherwise it's spam).
I did the subject part, and it works successfully.
The code is attached below. But I need help with the sender and the date part.
import pandas as pd
ExcelFile = pd.read_excel(r'C:\Users\Email Table.xlsx')
Subject = pd.DataFrame(ExcelFile, columns=['Subject'])
def spam(Subject):
df_multiindex = ExcelFile.set_index(['Subject'])
n = len(df_multiindex)
for x in range(n):
if ((pd.isnull(ExcelFile.loc[x, 'Subject'])) == True):
print("Spam")
else:
print("not spam")
spam(Subject)
You don't provide the format/type of your mail address, so this is just an idea. Check if the sender address ends with ".com":
You also do not provide information on how the date is formatted. Given a unix timestamp, it'd work like this: