#!/usr/bin/python
PERSON="Richard Kiss"
PERSON_EMAIL="him@richardkiss.com"
import cgi
import os
form = cgi.FieldStorage()
print "Content-type: text/html" # HTML is following
print # blank line, end of headers
def emailTheAddress(recipient):
print '''
Mail sent
The e-mail address for %s has been sent to %s''' % (PERSON, recipient)
# Import smtplib for the actual sending function
import smtplib
# Create a text/plain message
msg = "Subject: E-mail address for %s\nFrom: %s <%s>\nTo: %s\n%s can be reached by sending e-mail to <%s>." % (PERSON, PERSON, PERSON_EMAIL, recipient, PERSON, PERSON_EMAIL)
# Send the message via our own SMTP server, but don't include the
# envelope header.
s = smtplib.SMTP()
s.connect()
s.sendmail(PERSON_EMAIL, [recipient, PERSON_EMAIL], msg)
s.close()
def askForAddress():
print '''
E-mail Address Request
In an effort to reduce unsolicited e-mail ("spam"), you must enter your e-mail address before %s's e-mail address is revealed.
Enter an e-mail address to which you would like this information delivered.
''' % PERSON
if form.has_key("email"):
emailTheAddress(form["email"].value)
else:
askForAddress()