#!/usr/bin/env python3
import os
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart

apple_email = os.environ.get('APPLE_EMAIL', '').strip()
app_password = os.environ.get('APPLE_APP_PASSWORD', '').strip()
recipient = 'sage.stockmans@pm.me'

if not apple_email or not app_password:
    print('Missing APPLE_EMAIL or APPLE_APP_PASSWORD')
    exit(1)

msg = MIMEMultipart()
msg['From'] = apple_email
msg['To'] = recipient
msg['Subject'] = 'Reminder: Set up Pi-hole'
body = "Hey Sage! Don't forget to set up Pi-hole today if you haven't already."
msg.attach(MIMEText(body, 'plain', 'utf-8'))

with smtplib.SMTP('smtp.mail.me.com', 587) as server:
    server.starttls()
    server.login(apple_email, app_password)
    server.sendmail(apple_email, recipient, msg.as_string())

print('Email sent successfully from', apple_email, 'to', recipient)
