#!/usr/bin/env python import os, smtplib, getpass, socket username = getpass.getuser() hostname = socket.getfqdn() smtp = smtplib.SMTP('localhost') smtp.ehlo() email_from = username + "@" + hostname email_to = "comments@swatkins.fastmail.fm" http_host = os.environ.get('HTTP_HOST', hostname) page = "test" comment = """ hello world this is good! """ msg = """From: %(email_from)s To: %(email_to)s Subject: comment on %(http_host)s/%(page)s Context-Type: text/plain; charset=utf-8 %(comment)s """ % vars() msg = msg.replace("\n", "\r\n") smtp.sendmail(email_from, email_to, msg) smtp.quit()