Built a tool to auto reply to emails. Now I reply to spam faster than real people.
Was getting 30 cold emails a day minimum. Recruiters, sales pitches, people asking if I want to buy their course. Started replying manually with "not interested" but that ate 20 minutes every morning.
Thought hey I can automate this.
Version 1 was embarrassingly simple
Wrote a Python script that checked my Gmail every 5 minutes and sent "Thanks but not interested" to anything with keywords like "opportunity" or "partnership" in the subject.
import imaplib
import smtplib
from email.mime.text import MIMEText
imap = imaplib.IMAP4_SSL('imap.gmail.com')
imap.login('user@gmail.com', 'password')
imap.select('INBOX')
status, messages = imap.search(None, 'UNSEEN SUBJECT "opportunity"')
for num in messages[0].split():
msg = MIMEText('Thanks but not interested')
msg['Subject'] = 'Re: ...'
smtp = smtplib.SMTP('smtp.gmail.com', 587)
smtp.sendmail('user@gmail.com', sender, msg.as_string())
Ran for 2 days.
Then I auto declined a job I actually wanted. Oops.
Tried adding a whitelist
Figured I needed to NOT reply to:
- Domains I've emailed before
- Anyone in my contacts
- Emails with "interview" or "position" in subject
That helped until I replied to a vendor my boss was negotiating with. That conversation was awkward.
Current version pattern matches the body
Now it parses email content looking for:
- "I came across your profile"
- "quick call to discuss"
- Links to calendly or meeting schedulers
- Generic "reaching out" phrases
If 3+ patterns match and sender not in whitelist, auto sends "not currently looking for new opportunities".
spam_patterns = [
"came across your profile",
"quick call",
"calendly.com",
"reaching out",
"opportunity that might interest"
]
matches = sum(1 for pattern in spam_patterns if pattern in body.lower())
if matches >= 3 and sender not in whitelist:
send_auto_reply(sender)
Running for 3 weeks now. Handled 180 cold emails. Only 1 false positive where I replied to a conference organizer I should have responded to manually.
Still kinda weird that my script is more polite to strangers than I am.
Top comments (0)