Skip to content

Instantly share code, notes, and snippets.

@robweber
Created July 31, 2025 16:19
Show Gist options
  • Select an option

  • Save robweber/da3bf8f91820dc8ce1dca2ef33440cd9 to your computer and use it in GitHub Desktop.

Select an option

Save robweber/da3bf8f91820dc8ce1dca2ef33440cd9 to your computer and use it in GitHub Desktop.
Simple script to test sending an email through a specific email host
import argparse
import smtplib
import ssl
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
parser = argparse.ArgumentParser(description='Trash Panda Watchdog')
parser.add_argument('-H', '--host', default="localhost",
help="SMTP host")
parser.add_argument('-s', '--sender', required=True,
help="email sender")
parser.add_argument('-r', '--recip', required=True,
help="email recipient")
args = parser.parse_args()
email = MIMEMultipart("alternative")
email["Subject"] = "Test Notification"
html = "<html><body><p>this is an email test</p></body></html>"
email.attach(MIMEText("this is an email test", "plain"))
email.attach(MIMEText(html, "html"))
# Create a secure SSL context
context = ssl.create_default_context()
with smtplib.SMTP(host=args.host, port=25) as server:
server.sendmail(args.sender, args.recip, email.as_string())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment