Some webhosts make it a bit tedious to send email from your shell, and even harder inside your scripts or web apps. But setting up Django properly enables this to become a one-liner whenever you need it.
After some hunting around I found a help article at Webfaction describing the process of sending mail from a script (with Python, nice! give it a thumbs up; those guys are great). I could easily enough put some code like that into a function in a utility module to be called from various places, but it’s kind of ugly and repeats some data multiple times and requires a couple more imports. On a development box I got Django’s handy send_mail function to work, but even with the described smtplib setup work on the webhost, the Django convenience was not going to fly. But shortly into that Django article you see some setting parameters that are not part of the default django-admin-generated skeleton. I tried setting these like so:
if platform.uname()[1].lower() == 'myserver.webfaction.com':
EMAIL_HOST = 'smtp.webfaction.com'
EMAIL_HOST_USER = 'my_user_name'
EMAIL_HOST_PASSWORD = get_my_password()
And now I can simply send myself emails by making calls to send_mail, like this:
from django.core.mail import send_mail
...
send_mail("New beta user signed up!",
"%s\n%s" % (email, text),
"beta@mycompany.com", [ADMIN])